Brazil's left-wing incumbent Dilma Rousseff has come at the top of the presidential elections but has not gained enough votes to avoid a run-off and will face Aecio Neves.
With all votes counted on Monday, Rousseff led with 41.5 percent support compared with 33.6 percent for Neves.
Neves surged sharply in the pre-election period after intense campaigning with an emphasis on "safe change".
The prominent environmentalist Marina Silva was in third place with just 21 percent of the votes.
The top two will face each other in a second round on October 26.
The run-off will pit Rousseff's emphasis on robust social programmes and state intervention in the economy against Neves' vision of greater trade and a more austere state.
Silva, a former environment minister in Rousseff's Workers Party, seemed like Rousseff's probable challenger as recently as last week.
But her campaign abruptly fell apart under a barrage of negative adverts that accused her of being indecisive on issues such as taxes and gay marriage.
Rousseff accused Silva of seeking to cut some of her party's flagship welfare programmes which have lifted tens of millions out of extreme poverty over the past decade.
Neves is a favourite of capitalists demanding economic reform. He trailed Silva by 20 percentage points four weeks ago and sought to characterise her as a party clone in debates before the election.
Source: Al Jazeera and agencies