Brazilian presidential candidate Flavio Bolsonaro speaks to the media after casting his vote at a polling station in Rio de Janeiro. (EPA Images pic)

BRASILIA: Brazilian senator Flavio Bolsonaro, son of the far-right former leader Jair Bolsonaro, finished ahead of President Luiz Inacio Lula da Silva in Sunday's election, which will go to a run-off in three weeks.

In a surprise result that defied opinion poll projections showing Lula in the lead, Flavio Bolsonaro scored 47% of the vote to the incumbent's 45%.

If Bolsonaro triumphs in the Oct 25 election, Brazil will be the latest country to swing to the right in Latin America, a trend championed by US president Donald Trump.

The election results included a series of landslide wins for the right in parliament in a massive setback to Lula, who at almost 81 is seeking a fourth term in office to cement his legacy.