The train struck a building "with brutal force and collapsed like a cardboard box"
Rescuers said a further 18 people were injured. The victims, including some foreigners, have all been recovered from the wreckage, according to the emergency services.
The Portuguese government said the country would observe a day of mourning on Thursday to commemorate the victims, whose identities were not immediately available.
Footage showed police and rescue personnel working into the night around the mangled funicular lying on its side against a wall of the street.
A woman interviewed by the SIC television channel said the train, which can hold about 40 people, struck the building "with brutal force and collapsed like a cardboard box".
Videos shared on social media showed the mangled funicular on its side, surrounded by emergency responders.
Lisbon Mayor Carlos Moedas called the incident "a tragedy that our city has never seen".
A statement by the office of Prime Minister Luis Montenegro said it had "brought grief to... families and dismay to the country", and European Union chief Ursula von der Leyen offered condolences to the victims' families.
Lisbon prosecutors said they were opening an investigation into the accident's circumstances.
The city's public transport operator said it had complied with "all maintenance protocols".
"Everything was scrupulously respected," Pedro Bogas, the head of Lisbon Carris, said at the site of the accident, adding that maintenance of the funiculars has been done by a contractor for the past 14 years.
General maintenance is carried out every four years and was last conducted in 2022, Carris said. Intermediate maintenance takes place every two years and was completed in 2024.
Antonio Javier, a 44-year-old Spanish tourist, told AFP his family were "a little relieved" to have skipped taking the funicular because the queue was too long.
Tourists and residents alike use Lisbon's funiculars to travel up and down the capital's steep hills and the boxy yellow train is a common image on gift shop souvenirs.
The Gloria first entered into service in 1885 and was hooked up to electricity in 1915, according to the website of Portugal's national monuments.
The cause of the derailment is still under investigation, with the Judiciary Police’s Homicide Brigade involved.
Carris, the public transportation company operating the funicular, confirmed that its teams are on-site and “all means have been activated” to address the crisis.
An official source emphasised that the priority is monitoring the situation but provided no further details on potential causes.
Portuguese President Marcelo Rebelo de Sousa expressed his “deep regret” over the incident and extended condolences to those affected, according to a statement from his office.
European Commission President Ursula von der Leyen also shared her condolences in a Portuguese-language post on X.
Sign up for the Daily Briefing
Get the latest news and updates straight to your inbox