BUENOS AIRES — A blackout stripped all of mainland Argentina and Uruguay of power early Sunday, affecting tens of millions of people in an electrical failure that officials called unprecedented in its scope.

The cause remained under investigation by late Sunday, when power had been largely restored to both countries. Much of Argentina was hit by heavy rainfall over the weekend, and Uruguay’s state-owned utility, UTE, said some systems had been damaged by the recent rain and still needed to be repaired.

“This is the first time something like this has happened across the entire country,” said Alejandra Martínez, a spokeswoman for Edesur, an electricity company in Argentina that serves parts of Buenos Aires and its suburbs. She called it “a complete blackout in Argentina.”

The blackout may have affected a population greater than California’s, across a region four times the size of Texas: Argentina has more than 44 million people, and Uruguay about 3.5 million.