RIO DE JANEIRO — By the time Brazilians were done voting Sunday, mighty power brokers had been tossed out of office, long-dominant political parties had been humbled, and a far-right populist suddenly looked like he just might be the most powerful man in the country.

It was, in short, the most sweeping political shift Brazil had ever seen in a single election since democracy was restored in 1985.

“What we are watching today is the collapse of our current system,” said Maria Hermínia Tavares de Almeida, a political scientist at the University of São Paulo.

The near-winner in the first round of voting in the presidential race was Jair Bolsonaro, a former army captain. He offered few detailed policies. But his draconian approach toward fighting violence — he would make it easier to for the police to kill suspected criminals and imprison more people for longer — appealed to many in a nation traumatized by rising crime, a dispiriting economy and a political class widely regarded as venal and unresponsive.