In some of his first words to the nation as president-elect, far-right politician Jair Bolsonaro promised to defend the constitution and unite a bitterly divided populace.
His left-wing rival immediately vowed to mount a vigorous opposition, while rights groups warned against a rollback of civil liberties.
That juxtaposition underscored the reality that the end of the election was not the end of acrimony and that myriad challenges lay ahead for Latin America's largest nation.
Bolsonaro appeared to try to allay those concerns Sunday night, saying he would "pacify" Brazil following a race that revealed deep divisions and was repeatedly marred by violence. The candidate himself was stabbed and almost died while campaigning in early September, and there were numerous reports of politically motivated violence, especially directed at gay people.
"This country belongs to all of us, Brazilians by birth or by heart, a Brazil of diverse opinions, colors and orientations," he said, reading off a sheet of paper in a live television address.
His victory moved Brazil, the world's fourth-largest democracy, sharply to the right after four consecutive elections in which candidates from the left-leaning Workers' Party won.