Amid thunder and driving rain, Hugo Chávez stormed to the conclusion of his toughest presidential race yet on Thursday with a passionate address to hundreds of thousands of supporters in Caracas.

The mass rally transformed the city centre into a sea of cheering, dancing, red-shirted followers on the final day of campaigning before Sunday's vote, which looks likely to be the closest since the former tank commander won power in 1998.

The turn-out was bigger than the huge opposition rally staged last Sunday by his rival Henrique Capriles, who has narrowed the gap between the two candidates but is still significantly behind in most polls.

Chávez is the strong favourite, but few are predicting a landslide victory on the scale of past wins. Having battled cancer for most of the past year, he has been less visible than during previous campaigns.

With many in the electorate frustrated at high murder rates and declining infrastructure, the opposition believe this is their best chance to grab power.

But the president has repeatedly disproved his critics. Although some predicted his illness was so bad that he would not survive until election day, he has picked up the pace in the past week and looked robust on Thursday as he spoke, danced and sang on stage despite the torrential downpour.

"We are playing for life. In our hands we will not lose the fatherland, we will not lose the future of the fatherland," he proclaimed to a fervent crowd. He led a chorus of the national anthem, played air guitar to a campaign soundtrack and led his family on stage to huge applause.

But as well as triumphalism and defiance, Chávez has added an unusual degree of contrition in recent speeches, where he has tended to refer to himself in the third person: "I have made many mistakes, but I am here with all my soul. Chávez is not me. Chávez is the people," he said at a rally on Sunday. "Chávez will not fail you the next term … during the next term he will be a better president, more efficient, a better companion."

If he wins another term, aides say the president is preparing to do more to address security and economic concerns in recognition of the shortcomings that have eroded his popularity. But his core of support remains vast.

The crowds had been gathering in Bolívar Avenue and other major thoroughfares since the morning. Some had travelled hundreds of miles on overnight buses. Others had come by subway, motorbike or foot from the Caracas barrios to show their support for a politician whom they credit for doing more for the poor than any other leader in the country's history.

"I'm here to show support for Chávez because I've seen how the country has been transformed in the past 14 years," said Ligia Escalona, a law student from Lara state, who had left at 1am to make the long journey to Caracas. "Thanks to the education programs, people who have not previously had access to schooling are now literate and have an opportunity to go to college."

Many wore red and blue shirts emblazoned with the president's eyes or slogans declaring "Chávez, heart of the fatherland". Some wore hats bearing the portraits of the heroes of Latin America's left: Chávez, Simón Bolívar, Fidel Castro, Che Guevara, Rafael Correa and Evo Morales. Others carried banners reading "On the way to victory on 7 October."

The streets were filled with noise as well as colour: vuvuzelas, whistles, drums, loudspeakers playing salsa mixed with political lyrics, and chants of "Oh, aah, Chávez no se va" (Chávez won't go) – a slogan first heard after a failed 2002 coup against the president.

Junior Landaetta, a police student, had come with a samba band to add to the fiesta spirit. Aged 18, he is part of a new generation who will vote for the first time on Sunday – a key segment of the electorate in a country that has undergone rapid population growth in recent years.

"I'll vote for Chávez until death," he said as his band passed by the Congress building. "He has done so much for the country. If Capriles wins, I think everything will fall to pieces."

Polls, analysts and the electorate are sharply divided about the likely outcome, but there is widespread agreement that Chávez has lost some of his previously enormous support.

"The serious polls show Chávez will win by about 14%. But I can see that Capriles has done a good campaign and that the gap has been closing in the last few days. It might now be between 7 and 10 points," said Nicmer Evans, a left-leaning political scientist at the Central University of Venezuela. "The main reasons why Chávez's popularity has waned is flaws in management. Although he has been very successful in creating political consciousness, Chávez accepts criticism about the quality of the revolution."

"I think it will be close and that Capriles will win," said Teodoro Petkoff, a former Marxist guerilla, founder of the Socialist party and former presidential election challenger. "If the gap is just 1 or 2 points for either contender, it could unleash violence."

Close aides of the president dismiss rumours of possible unrest, saying the president will accept the result, whatever the outcome.

But his supporters on the streets said they would defend the gains they have won under Chávez. "Capriles is a wolf in sheep's clothing. He would dismantle everything we've built," said Henry Reveron, a former peasant who has been able to train as a lawyer under one of Chávez's social "misions".

"If Chávez loses, we'll go into unwavering opposition. This is a peaceful revolution, but if needed we'll go into the mountains and fight with our nails, teeth, arms and whatever is necessary. Venezuela is no longer naive."