The power cut hit famous sights like the Copacabana beach
A severe storm has been blamed for widespread power cuts in Brazil which lasted more than five hours, the government said.
The strong winds, heavy rain and lightning brought down a power line in Brazil, cutting two other lines and ultimately shutting Itaipu dam.
In the worst blackout to hit Brazil in years, up to a fifth of the population was left without power on Tuesday.
Neighbouring Paraguay was also briefly left in the dark.
Initial suspicion had focused on the Itaipu hydroelectric plant, which supplies 20% of Brazil's power, but officials there said the facility was working normally.
Energy Minister Edson Lobao said the bad weather cut the transmission lines in Sao Paulo state, leading the huge Itaipu dam to shut down automatically.
"Our grid is strong and resistant, but there are moments that the system simply can't withstand," he told reporters in the capital Brasilia.
The outage caused chaos on the streets of major Brazilian cities, including Sao Paulo and Rio de Janeiro, which will showcase the 2014 World Cup and host the 2016 Olympics.
At least 10 Brazilian states were partially or totally affected with problems spread over a wide geographical area, from Recife in the north-east to Rio Grande do Sul in the far south.
President Luiz Inacio Lula da Silva dismissed claims that his government had failed to maintain the infrastructure.
He said investment in transmission lines over the last seven years amounted to 30% of what had been spent over the preceding 120 years.
"We didn't have a failure in the generation of energy, we had a problem in the transmission line," Mr Lula said.
The government will be under considerable pressure to ensure that such a drastic power failure is not repeated, the BBC's Gary Duffy reports from Sao Paulo.
'Hostage to accidents'
Itaipu Binacional, the company which runs the hydroelectric plant, said the problem had originated elsewhere.
It said the dam had been functioning normally, but had not been able to transmit energy because power lines were not working.
Adriano Pires, director of the Brazilian Center for Infrastructure Studies, said Brazil's transmission lines were "very badly maintained".
"This shows that Brazil is very vulnerable," he added.
"You can't leave a country the size of Brazil hostage to accidents."
'Bad enough already'
Sao Paulo's roads were still clogged with traffic early on Wednesday after the mayor cancelled restrictions on the amount of cars allowed to circulate at rush hour.
One BBC News website reader, Phil Badiz, wrote to say that Sao Paulo was a "city in post-reboot" on Wednesday.
"Only cars were illuminating the city for as far as the eye could see," he said in his account of the blackout.
In Rio many tourists left their hotel rooms along Copacabana beach because of the lack of air conditioning and milled around on the unlit streets.
A group of muggers took advantage of the darkness to rob people en masse near Rio's Maracana stadium, which will host the Olympics' opening and closing ceremonies, the Associated Press news agency reports.
But overall, police said, crime did not rise in Rio and actually fell in Sao Paulo during the outage.
"The image of Brazil, of Rio, is bad enough with all the violence," said graphic designer Paulo Viera, 35, as he stood in a restaurant near Copacabana.
"We don't need this to happen. I don't know how it could get worse."