What happens in Venezuela now matters more than at any time in the country's history - not just for Latin America, but for the wider world. Since the leftwing nationalist Hugo Chávez was first elected in 1998, his oil-rich government has not only spearheaded a challenge to US domination and free-market dogma that has swept through the continent. It has also led the first serious attempt since the collapse of the Soviet Union to create a social alternative to the neoliberal uniformity imposed across the globe. That has become even clearer since the Venezuelan president committed his "Bolivarian revolution" to introducing a new form of "21st century socialism" two years ago.

So it's hardly surprising that Chávez's wafer-thin defeat in the constitutional referendum at the weekend has been seen as more than a little local difficulty. The proposals would have allowed him to stand again after his term as president expires in 2012; formalised Venezuela as a socialist state; entrenched direct democracy; and introduced a string of progressive reforms, from a 36-hour working week and social security for 5 million informal workers, to gay rights and gender parity in party election lists. Their defeat by 50.7% to 49.3% was hailed by George Bush and greeted with dismay by supporters at home and abroad, not least in countries such as Cuba, Bolivia, Ecuador and Nicaragua which rely on Venezuelan support. At the Miraflores presidential palace in Caracas in the early hours of Monday morning, the shock among ministers and activists was palpable.

But although the referendum result was clearly a setback for the charismatic Venezuelan president, it is also very far from being any kind of crushing defeat. Chávez remains firmly in power, with a commanding level of public support - his poll ratings are still over 60% - and control of the national assembly. With the exception of his right to stand again, most of the referendum package can be legislated for without constitutional authorisation. Through a dignified response to the opposition's victory, acknowledgement of a failure of preparation and commitment to stick with the attempt to build socialism, Chávez has already regained the political initiative.

Perhaps most importantly for understanding what is actually going on in Venezuela, the referendum result has surely discredited the canard that the country is somehow slipping into authoritarian or even dictatorial rule. It is clearly doing nothing of the sort, though doubtless if Chávez had won by a similar margin the US-backed opposition would have cried foul and much of the western media would have accused Chávez of dictatorship. I visited over half-a-dozen polling stations on Sunday in the state of Vargas, north-east of Caracas, and in the city itself, and the process was if anything more impressively run than in Britain - and certainly the US - with opposition monitors everywhere declaring themselves satisfied with the integrity of the ballot.

Of course, the campaign was the focus of the most mendacious propaganda, both at home and abroad. There was not only the absurd claim, recycled endlessly through the international media, that the new constitution would make Chávez "president for life" (rather than subject to the same rules that operate in France or Britain). In Venezuela, anonymous advertisements indirectly paid for by US corporate interests ran for days in the best-selling paper insisting that, if the constitutional reforms were passed, children would be taken from their parents and private homes nationalised.

Anecdotal evidence suggests such nonsense had some impact. The Bush administration has been funding elements of the opposition, including student groups (as reported at the weekend in the Washington Post), which were at the forefront of the "no" campaign. But after winning 11 national votes in nine years, the Chavista movement was clearly also complacent: the process was rushed; and there was a lack of clarity among many Chávez supporters over what was really at stake. Milk shortages that suddenly materialised in the last couple of months certainly didn't help. There is also discontent over crime and corruption, including the role of the "boli-bourgeoisie" grown rich under his presidency. Crucially, it was the abstention of Chávez supporters, especially in poorer areas, rather than greater support for the opposition, that lost the vote.

That suggests those voices in the Chávez camp now calling for slower and less radical reforms may be missing the point. The revolutionary process underway in Venezuela has already delivered remarkable social achievements in a society grotesquely disfigured by inequality, by redistributing oil revenues and unleashing direct democracy to push through social programmes. As Teresa Rodriguez, a mother of three, told me at a meeting of one of the new grass roots communal councils in the Catia barrio in Caracas: "We didn't have a voice, now we have a voice."

Since Chávez came to power, the poverty level has been slashed from 49% to 30%, extreme poverty from 16% to below 10%; free health and education have been massively expanded; subsidised food made available in the poorer areas; pensions and the minimum wage boosted; illiteracy eliminated; land redistributed; tens of thousands of co-ops established, and privatised utilities and oil brought back under public ownership and control.

It might be imagined that such a record - for all its weaknesses - combined with the clear demonstration of Venezuela's democratic credentials this week would attract more sympathy among some of those in the west who claim to care about social progress. Presumably concerns about Chávez's fierce opposition to US imperial power bother them more than the reality of life for Latin America's poor.

But there's little doubt that the fate of the Venezuelan experiment will have an impact far beyond its borders. So far, the cushion of oil has allowed Chávez and his supporters to make rapid progress without challenging the interests of the Venezuelan elite. The dangers of the movement's over-dependency on one man - not least from the threat of assassination - were underlined by the referendum experience. What is certain, however, is that the process cannnot stand still if it is to survive - and to judge by Chávez's response to his first poll defeat, he is in no mood for turning back. We weren't successful, he told the country, "por ahora" - for now.