Dilma Rousseff, the Workers' party candiidate, will face Social Democrat José Serra in the second round of Brazil's presidential election Reuters

A late surge by the Green party candidate has forced Brazil's presidential election into a second round, with Luiz Inácio Lula da Silva's favoured successor narrowly failing to become the nation's first female leader.

Exit polls had suggested Dilma Rousseff, a former leftwing rebel, might still scrape a narrow first-round victory despite falling away in the polls in recent weeks. But the Workers' party (PT) candidate fell short of the 50% needed, taking 47% of the vote.

The Greens' Marina Silva, a former rubber-tapper and staunch defender of the Amazon rainforest, got 19%, while Rousseff's main rival, José Serra, the Social Democrat, took nearly 33%. Rousseff will face Serra in the second round on 31 October.

Silva, who quit as Lula's environment minister after reputedly falling out with Rousseff, will not dispute the second round. But her higher than expected result stripped vital support from Lula's candidate and transformed her into a potential king or queen-maker in the second round.

Speaking after the result a visibly ecstatic Silva said the country now had a "second chance to debate Brazil's future, present and past".

"These results are the worst imaginable for the government," Merval Pereira, a respected political columnist, told TV Globo, pointing to a PT defeat in the race for governor of São Paulo as well as Rousseff's failure to achieve an outright win. "Dilma's vote was far below what the polls predicted."

Flanked by stony-faced allies, a noticeably subdued Rousseff tried to put on a brave face claiming a second round would give her "more time" to detail her proposals.

"We are used to challenges and traditionally we have done very well in second rounds," she said. "This second stage will start tomorrow … and for me it has been very important to have got this far."

While Rousseff, Lula's former chief of staff, has the endorsement of Brazil's hugely popular leftwing leader and remains the favourite, she lacks her mentor's charisma. Some voters remain unsure of her name, referring to the presidential frontrunner simply as "Lula's woman". One voter in Rio de Janeiro told the Guardian this week he planned to vote for Lula's candidate, "Telma".

Political analysts are divided on which candidate Marina Silva might support in the second round – if she supports anyone at all. One recent poll suggested a significant number of her voters could shift their support to Jose Serra rather than Rousseff in the runoff.

In the run up to the campaign Serra reportedly attempted to convince Silva to stand as his vice-presidential candidate but his approaches were rejected. Analysts suggest he may now repeat his offer or look to Fernando Gabeira, another prominent Green party member who has lost out in the race to become Rio de Janeiro's governor.