Power has nearly been fully restored in Ecuador after a nationwide electricity outage struck residential users, hospitals as well as the capital's subway system, a failure officials blamed on faulty transmission lines.

Public Works Minister Roberto Luque said in a post on X that 95% of service had been restored by evening on Wednesday.

The outage left the nation of some 18mn in the dark, as the minister also singled out insufficient maintenance as a contributing factor.

"What happened today is just more proof of the energy crisis we're dealing with," he said, ticking off recent problems caused by insufficient power generation that has led to unscheduled service cuts.

Luque, who also serves as acting energy minister, stressed that the outage was due to a lack of investment in transmission that could have been avoided.

Luque had earlier in the day pinned the blame on a transmission line failure that caused "a cascade disconnection”.

The blackout hit abruptly just after 3pm local time on Wednesday, surprising subway riders in the capital Quito as trains came to a halt and hundreds of people were evacuated.

Some were forced to walk long distances through dark metro tunnels until finding an exit.

Traffic lights in Quito went on the blink and police manned intersections to maintain some semblance of order in the city of 3mn people.

"The incident must have been major because it even knocked out power to the metro, which has its own separate system," Quito Mayor Pabel Munoz said on X.

He had ordered the deployment of special teams to help anyone who may be trapped, prevent accidents and "take care of public spaces”.

Traffic chaos also hit the Pacific port city of Guayaquil, an AFP correspondent observed.

People found themselves stranded in elevators in office and residential buildings and the public water company urged the population to stock up just in case.

Street cars in the southern city of Cuenca also stopped running.

In Santo Domingo de los Tsachilas, in the centre of the South American country, the situation was similar, and traffic agents had their hands full.

The education ministry suspended night classes for the duration of the blackout for safety reasons.

In April, Ecuadorean President Daniel Noboa declared an energy emergency and announced planned electricity cuts.

While the South American country has struggled with a drought affecting hydro-electricity power generation, heavy rains over the weekend forced authorities to take three hydroelectric plants offline.

The weekend rains provoked a landslide that killed at least 17 people and left dozens injured.

The disaster also prompted Ecuador's private OCP oil pipeline to suspend operations and declare force majeure.

Ninety-two per cent of the country's electricity comes from hydroelectric plants.