Brazil is headed to a runoff after Flávio Bolsonaro finished first in Sunday's presidential vote, beating President Luiz Inácio Lula da Silva. With all ballots counted, Bolsonaro had 47.03% of valid votes to Lula's 45.16%, according to the final count reported by O Globo. That is about 56.1 million votes to 53.9 million. Since no one passed 50%, the two face each other again on Oct. 25.

The result beat the polls. Lula had led slightly during the campaign. The BBC says the runoff now looks like Bolsonaro's to lose, because several knocked-out candidates were also on the right. Bolsonaro's Liberal Party also won the most governors, senators and federal deputies so far.

Lula, 80, is seeking a fourth term. He was elected in 2002, 2006 and again in 2022, when he beat Jair Bolsonaro by less than 2 points, the closest race in Brazil's history. After that loss, Bolsonaro supporters stormed government buildings on Jan. 8, 2023. Jair Bolsonaro is now serving a 27-year prison sentence for plotting a failed coup. He was barred from running and backed his eldest son, Flávio, 45. Flávio has pledged amnesty for his father and the Jan. 8 rioters if he wins.

Lula called the result unexpected. "We are in extra time," he said Sunday night. He has framed the race as a choice between democracy and what he called "barbarism."

Brazil's top electoral court said Sunday it found no evidence of foreign interference in the vote. Former first lady Michelle Bolsonaro, Jair's wife, was elected to the Senate, the BBC reported.

Investors cheered. Analysts quoted by Reuters expected Brazilian stocks and the real to rally Monday on hopes of tighter spending under Bolsonaro.

What we know: The runoff is Oct. 25 between Bolsonaro and Lula.
What we don't: Which way voters for eliminated candidates will break.