The comandante had not shown up for the rally, disappointing supporters in the sun-baked plaza, a triangle of cracked concrete amid a bustling outdoor market, but they made the best of it. A convoy of cars and trucks adorned with posters of the familiar jowly, smiling face slowly circled, blasting campaign songs from huge speakers. A middle-aged woman in red leggings shimmied to the beat of a campaign song blasting from speakers.

Another handed out flyers with the election manifesto which outlined "five great historic objectives". One: "Defend, expand and consolidate national independence." Two: "Continue building Bolivarian socialism of the 21st century in Venezuela as an alternative to destructive and savage capitalism." Three: "Make Venezuela an economic, social and political power within the growing power of Latin America and the Caribbean." Four: "Develop a new international geopolitics forming a multicentric and pluripolar world to achieve equilibrium in the universe and guarantee planetary peace." Five: "Preserve life on the planet and save the human species."

No one ever accused Hugo Chávez of thinking small. He casts politics as an existential contest between good and evil, the oppressed and the oppressor. The next battle is on Sunday, when he seeks a third term to extend his 14-year rule to 2019. There is a clenched tension in the streets, for no one knows what will happen. Some polls give the president a wide lead, others show him trailing. Wild rumours fill the air: Chávez's family is selling its cattle herds and trucks in anticipation of fleeing to Cuba; pro-Chávez militias are preparing to seal off parts of Caracas; the opposition is planning to assassinate Chávez. Nonsense, but people are worried enough to stockpile water, batteries, tinned food and toilet paper.

The election will decide the fate of Chávez, 58, and his revolution. Lose, and the revolution dies. Win, and it survives, but only for as long as the leader has a pulse. Chávez, Gabriel Garcia Marquez once noted, had "a body of reinforced concrete". His energy was superhuman, his appetites prodigious. He drank more than 30 shots of sweet, black coffee daily, fuelling a routine that included 3am phone calls to ministers and aides. No longer. Cancer treatment has bloated and debilitated the comandante. After his diagnosis Chávez changed the slogan "Fatherland, socialism or death" to "We will live and we will win". All references to "muerte" in official discourse have been expunged. "There will be no death here, we must live," he instructed. But few believe his claims to be cured of a disease whose exact nature and location remains a closely guarded secret. Some palace insiders whisper it is terminal.

The revolution hangs by a thread. There appears to be no plan B, no successor. Chávez surrounded himself mostly with mediocrities, valuing loyalty over competence or, it turned out, honesty. With the chief ailing they look lost. A rally in Catia, a Chávista bastion near the presidential palace, Miraflores, was abruptly cancelled in disarray. The foreign minister, Nicolas Maduro, put on a brave face but a microphone caught his murmured words: "Que cagada." What a fuck-up. Not elegant but if Chávez loses it will be the campaign's epitaph.

Chávez's absence from many rallies has given him the air of Banquo's ghost. He hovers in the form of television appearances, and occasional, relatively brief public appearances, an echo of the man who used to barnstorm the country and wade into crowds. Winning the election under such circumstances would be a triumph, and he may well pull it off, but it will not shake off the sense of fin de regime.

His legacy will be debated for decades, much as people still argue over Juan Peron in Argentina. Many outsiders made up their minds long ago. There was Chávez the dictator who jailed opponents, sponsored terrorists and left his people hungry. And there was Chávez the hero who empowered the poor, deepened democracy and stood up to the US. While based in Caracas for the Guardian from 2006 to March this year I would hear both versions on trips abroad. Dublin, Shanghai, San Francisco, it didn't matter where, opinion was polarised and passionate. And completely depressing. This was Venezuela of fantasy, a cartoonish projection, each side parroting simplicities and distortions as revealed truth. The reality was more complex and fascinating but if I broached oil dependency, or details that determined the fate of the revolution, eyes would glaze over. Few wanted to hear nuances of political economy. They wanted tales of the demon or gospels of faith.

There was, arguably, a duality to Hugo Chávez. The poor boy from the plains who loved to sing and tell stories rose up army ranks and attempted a bloody coup in 1992 against an unpopular but democratically elected government. Six years later he took Miraflores via the ballot box but in power created a personality cult, abolished term limits, curbed private media and put the armed forces, legislature, judiciary and state oil company, PDVSA, under his personal control. He turned a blind eye to Farc guerrilla camps near the Colombian border and hailed the likes of Mugabe, Gaddafi and Assad as brothers.

But the same president was adored by millions of his people, won free (if not always fair) elections, survived a US-backed coup, accepted electoral defeat (a 2007 referendum), spent oil revenues on health clinics, literacy courses and social programmes, slashed poverty, devolved power to communal councils, stood up to George Bush over Iraq, encouraged regional pride and assertiveness across Latin America and did it all with charisma and flair. The occasional clowning and buffoonery which grabbed headlines concealed a shrewd, sophisticated political mind.

Chávez, in other words, was – is – a hybrid: a democrat and autocrat, a progressive and a bully. His "Bolivarian revolution", named after the 19th-century revolutionary Simón Bolivar, has embodied these contradictions. What, then, has it wrought these 14 years?

For Ruth Guerrero, a Chavista canvasser in Petare, a hillside slum in eastern Caracas, the answer was simple. "Hope." The 56-year-old mother of three grew up poor and unemployed, unable to follow a yen for learning. Thanks to "Mision Robinson", an adult education course, one of myriad social programmes, Guerrero obtained a law diploma and now earns $380 a month teaching at a Bolivarian university. "Before that I had lived a life full of injustice. Chávez has been my teacher and leader."

Guerrero's effort to hand out leaflets garnered little attention from passers-by, however, and she feared friends and neighbours would abandon Chávez. Polls show Petare voting for the opposition. "I'm worried. I keep telling them that the president doesn't like rubbish in the streets, or potholes, or insecurity, that he wants us to tackle them together."

Guerrero was referring to the single most damning critique of the revolution, one that has nothing to do with Chávez's democratic credentials. Venezuela is falling apart. In the case of infrastructure, literally. Roads are crumbling, bridges falling, refineries exploding. A wheezing power grid condemns much of the country to rolling blackouts. Public hospitals, with a few exceptions, are dank, dingy affairs where patients must supply their own bedsheets, bandages and food.

Prisons are filthy and riven by violence which claimed 500 lives last year. To massage statistics there was a tacit deal between authorities and some gang leaders to hang victims so they could be counted as suicide, a mid-ranking penal official told me. She had armfuls of documentation and grisly photographs. "But how can I use it? If I do, I'll be fired, lose my pension and then be prosecuted."

Murder rates have more than doubled, filling morgues and making Caracas deadlier than Baghdad, reflecting an underfunded, politicised judicial system. Kidnappers, sometimes in league with police, snatch victims from cars, shopping malls, university campuses and bus stops. A recent security plan did not reassure – by some counts it was Chávez's 20th such initiative. Lack of security is one reason so many young Venezuelans are emigrating, giving Caracas the melancholy nickname City of Farewells.

The economy is not falling apart. It is growing about 5% this year, with unemployment of around 8%. It is, however, warping. Under Chávez Venezuela, which claims bigger oil reserves than Saudi Arabia, has seen prices leap from $9 a barrel to over $100, gushing about $980bn through PDVSA.

Ahistoric bonanza begging a big question: where is the cash? Social programmes and subsidies – you can fill a car's petrol tank for around 50 cents – account for some, as do arms purchases and (mostly stalled) infrastructure projects. But much vanished. Chávez is no Mobutu. He did not build palaces in the jungle to store pink champagne. He did, however, create a tangle of economic controls which let opportunists in government, and those with friends in government, siphon off billions of public money.

Few outsiders grasp how profoundly restrictions such as Cadivi – a currency control agency that tried to shore up the ever weakening Venezuelan bolivar – perverted the economy and spawned a class of high-rolling parasites nicknamed "boligarchs". Chávez occasionally complained about them but let them get rich as long as they supported the government.

Their revolution has been one of dodgy bond issues, government contracts and currency manipulation, yielding yachts, Rolexes and Hummers. They pay fashion designers such as Giovanni Scutaro, who used to dress Chávez, astonishing sums for outfits. "When people from the United States and Europe come here and see our weddings, they go: 'Wow, so much money.' There is no equilibrium between perceptions from afar and the reality of what is happening inside the country," Scutaro says.

Last week a Reuters investigation detailed how more than half of public investment churns into secretive funds controlled by Chávez with no oversight by auditors or congress.

One fund, called Fonden, swallowed about $100bn. Some was spent on white elephants – an abandoned newsprint factory, a "city of aluminum" – and on ill-fated investments in Ecuadorean bonds and Lehman Brothers-issued derivatives. In a functioning, accountable democracy this would be a huge scandal but Venezuela's government – plus state prosecutors and media – ignores it. "That is not Chávez's money. That money belongs to 29 million Venezuelans and as such the information should be available to everyone," said Carlos Ramos, an opposition legislator.

Harassing the private sector – investment evaporated amid expropriations – and bungled management of multiplying state enterprises translated into shrivelled agriculture and industry. Huge imports to fill the gap, though you would never guess it from Orwellian rhetoric trumpeting "food sovereignty" and "manufacturing independence". The result is increased dependence on oil, now accounting for 96% of export earnings versus 80% a decade ago. That is why so many Venezuelans end up on pavements selling knick-knacks (they are counted as employed), or watching the clock in decaying state enterprises.

This does not add up to collapse. There are always petrodollars to stuff into cracks. But analysts say that, regardless of who wins the election, Venezuela faces a grim economic reckoning. The economy is growing now only because of a splurge in government spending and borrowing, mostly from China.

In the headquarters of PDVSA, his office overlooking Avenida Libertador, one of Chávez's top oil officials told me that the boss started as a pragmatist but turned ideological after opponents tried to oust him in a 2002 coup and general strike – soon after which oil revenues began booming. Then, in hushed tones of heresy: "It was a historic opportunity that was wasted. He doesn't understand economics. Chávez doesn't know how to manage. As a manager he's a disaster."

Venezuela's revolution has no gulags, no torture chambers, but in wasted potential lies tragedy. Here was a sublimely gifted politician with empathy for the poor and the power of Croesus – and the result, fiasco.

Neither side likes to acknowledge it but the revolution is in many ways a continuum of oil-fuelled populism dating back half a century, notably that of the giddy, spendthrift 1974-79 administration of Carlos Andres Perez, the mercurial president Chávez tried to overthrow in 1992. The difference is Chávez had even more money, more power, more showmanship.

It was easy to overlook the blunders while he strutted the stage, singing and dancing, blowing kisses, riding a bike, a horse, a tank, holding court from his desk, blending folk tales with ideological thunder, commandeering airwaves to talk and talk, sometimes for eight hours straight, oratorical marathons which exhausted aides, paralysed opponents and sucked up the oxygen.

If Chávez were healthy he would have walked this election, his skills of enchantment steeled, as ever, by control of state resources and institutions. Instead, he has rationed his public appearances and relied on television to simulate the magic of old while his youthful opponent, Henrique Capriles, bursts into villages, towns and cities denouncing their dilapidation.

When visiting the Caruachi hydro-electric plant to whip up support Chávez suffered the indignity of being heckled by workers demanding unpaid wages and the restoration of collective-bargaining rights. His microphone failed and a back-up sound system transmitted what sounded like shouts of "justicia", justice, at which point state television cut the broadcast. A nation accustomed to highly choreographed presidential events with handpicked audiences gasped at the glimpse behind the curtain.

Chávez can boast genuine accomplishments. He put poverty and social exclusion at the forefront of debate. He made millions feel they had an ally in government. And he called time on US browbeating in Latin America. But the price was high. Gutted institutions, a caudillo (strongman) cult, economic dysfunction. After a recent spate of bad news – a prison riot, a collapsed bridge, an oil refinery accident – Chávez reached for a telling metaphor. "The show must go on." Maybe it will, maybe he will win, and live to rule. But what cost the spectacle?

• Rory Carroll's book about Chávez, Comandante, will be published next March by Canongate in the UK and by Penguin Press in the US.