Searchlights illuminated the night sky above the RecNov television centre in western Rio and rain poured down on to the sprawling factory of tear-jerking Brazilian soap operas. Inside Studio J a 62-year-old woman, clad in white, stared into the camera and began her pitch.

"I represent a project to transform Brazil," she told the millions of Brazilian voters who had crowded around TV sets from inner-city Rio to remote Amazon towns. "Yes, it is possible for a woman to be the president of the republic and I know you will support this project."

It was just after 9pm and Dilma Rousseff, a dog-loving, Proust-obsessed former Marxist rebel, was basking in her role as the grande dame of Brazilian politics. By Sunday she may well also be the country's first "presidenta", as Luiz Inácio Lula da Silva, the country's first working-class leader, comes to the end of his second term in office.

"Women are ready to govern Brazil and more importantly Brazil is ready to be governed by a woman," Rousseff, a member of Lula's Workers Party (PT) since 2000, said in a recent interview, adding that women were "sensible, practical and sensitive". "These are important qualities for someone who wants to govern a country.".

A career civil servant, Rousseff is notorious for lacking the personality of her charismatic mentor, Lula. Yet her story is scarcely less compelling. Born to a Bulgarian father and a Brazilian mother, Rousseff spent nearly three years behind bars after clashing with Brazil's dictatorship before rising to become one of the country's most powerful women. South America's largest democracy goes to the polls on Sunday, and Rousseff currently tops the polls with about 50%.

Fernando Pimentel, the former mayor of Belo Horizonte and one of Rousseff's oldest friends, charts her political awakening back to her high-school days when she became involved in social work in one of the city's oldest favelas, the Morro do Papagaio. The impoverished hillside slum near her upmarket childhood home provided her first glimpse of Brazil's vast inequalities.

"It gave her a certain contact with poverty which she wouldn't otherwise have had, coming from a middle-upper-class family," Pimentel said.

After leaving school in the mid-1960s, Rousseff and Pimentel grew increasingly involved in politics. As Brazil descended into the repressive 1964-1985 dictatorship the pair joined the underground National Liberation Command, or Colina group. While she denies involvement in violence, saying she was too short-sighted to use a rife, she says: "I was good at cleaning a gun. I still know how to take one apart and put it back together again."

In 1970 Pimentel and Rousseff, who had gone into hiding in different parts of Brazil, were arrested and spent several years in military jails. They were tortured with electric shocks and beatings.

On release Rousseff relocated to southern Brazil and completed an economics degree before starting life as a public administrator. In 1986 she became Porto Alegre's finance minister, the first of many administrative posts that eventually led to a place in President Lula's cabinet, as energy minister, then chief of staff.

Pimentel said Rousseff was "an avid reader … with an enormous intellectual curiosity. She reads everything from classics such as Proust to books about macro-economics." Recently she had been swotting up on Brazil's Latin American neighbours, he said.

This year, for the first time in Brazilian history, there are two women at the forefront of the presidential race. Also running is the rainforest defender and Green party member Marina Silva, who has around 14% of intended votes.

Fátima Pacheco Jordão, a Brazilian sociologist from the Patrícia Galvão Institute, said it was "absolutely unprecedented" to have two competitive female candidates running for the presidency. "I think it brings us a great potential for change," said Jordão, adding that voters saw in a female candidate the possibility of "new values and new ways of doing politics".

"The historic absence of women in politics has meant that society has been able to see in … [Rousseff] something that represents an advance, that represents a correction of Brazilian politics in terms of corruption, equality and the gender divide," she said.

"I'm convinced that a great part of Dilma's success is down to her being a woman, and not just about the support of President Lula," she added.

The role of women in Brazil's 2010 elections is not just about the candidates. With Rousseff keen to avoid a second round, analysts say female support, particularly in the south-eastern states of São Paulo and Minas Gerais, will prove decisive. "The female vote is absolutely strategic for defining whether there will be a second round or not," said Jordão. "If Dilma can win over female voters in these states she'll seal it in the first round. The women will decide."

The candidates know this. Rousseff has portrayed herself as the "mother" of Brazil's economic advances, while, at Sunday's debate, Marina Silva urged Brazilians to vote for an all-female second round, promising "a dignified life for every Brazilian, above all for Brazilian women".

"After 500 years Brazilians want a woman as president of the republic," she said after the debate.

Rousseff's main opponent, the Social Democrat José Serra, attacked the current administration's ties with Iran. "Over the last few years the Brazilian government has allied itself with dictatorial regimes, like Iran's, that persecute and mistreat women," he said.

Such criticism is unlikely to change the election's outcome. While a recent string of corruption allegations against the government have seen Rousseff dip slightly in the polls, few believe they will derail her bid to become president.

"We have lifted 28 million people out of poverty and put 36 million Brazilians into the middle classes," Rousseff boasted, back at the RecNov studios. "This is not about me. I intend to make the dreams of millions of Brazilians come true."