If you want to learn about human rights in Venezuela before Hugo Chavez, type “Caracazo” into Google, and do so with a strong stomach. Back in 1989, then-President Carlos Andrés Pérez won an election on a fiery platform of resisting free-market dogma: the IMF was “a neutron bomb that killed people, but left buildings standing,” he proclaimed.

But after safely making it to the presidential palace, he dramatically u-turned, unleashing a programme of privatisation and neo-liberal shock therapy. With gas subsidies removed, petrol prices soared, and impoverished Venezuelans took to the streets. Soldiers mowed protesters down with gunfire. Up to 3,000 perished, a horrifying death toll up there with the Tienanmen Square Massacre – in a country with a population 43 times smaller.

It was his abortive coup attempt against Pérez's murderous, rampantly corrupt government in 1992 that launched Chavez to prominence. Though locked away, Chavez became an icon for Venezuela's long-suffering poor. By the time he won a landslide victory in 1998 on a promise to use the country's vast oil wealth to help the poor, Venezuela was a mess. Per capita income had collapsed to where it had been in the early 1960s. One in three Venezuelans lived on less than $2 a day. Oil revenues were squandered.

Download the new Independent Premium app Sharing the full story, not just the headlines

Over the coming days, you will be repeatedly told that Hugo Chavez was a dictator. A funny sort of dictator: there have been 17 elections and referenda since 1998. Perhaps you think they were rigged. When he won by a huge margin in 2006, former US President Jimmy Carter was among those declaring he had won “fairly and squarely”.

At the last election in October 2012, Carter declared that, “of the 92 elections that we've monitored, I would say the election process in Venezuela is the best in the world.” I was there: perhaps you think I was like those hopelessly naïve Western leftists who visited Potemkin villages in Stalinist Russia.

I was with a genuinely independent election commission, staffed with both pro-Chavez and anti-Chavez sympathisers, who had previously been invited by the opposition to run their own internal elections. We met with senior opposition figures who railed against Chavez, but acknowledged that they lived in a democracy. When they lost the election, they accepted it.

Social justice

Indeed, Chavez himself has had to accept defeat before: back in 2007, he lost a referendum campaign, and did not quibble with the results. Until he came to power, millions of poor Venezuelans were not even registered to vote: but dramatic registration drives have nearly doubled the electorate. There are 6,000 more polling stations than there were in the pre-Chavez era.

On the other hand, the democratic credentials of many of his opponents can certainly be questioned. In 2002, a Pinochet-style coup was launched against Chavez, and was only reversed by a popular uprising. Much of the privately owned media openly incited and supported the coup: imagine Cameron was kicked out of No 10 by British generals, with the support and incitement of rolling 24-hour news stations. But Venezuela's media is dominated by private broadcasters, some of whom make Fox News look like cuddly lefties. State television could rightly be accused of bias towards the government, which is perhaps why it has a measly 5.4 per cent audience share. Of seven major national newspapers, five support the opposition, and only one is sympathetic to the government.

The truth is that Chavez won democratic election after democratic election, despite the often vicious hostility of the media, because his policies transformed the lives of millions of previously ignored Venezuelans. Poverty has fallen from nearly half to 27.8 per cent, while absolute poverty has been more than halved. Six million children receive free meals a day; near-universal free health care has been established; and education spending has doubled as a proportion of GDP. A housing programme launched in 2011 built over 350,000 homes, bringing hundreds of thousands of families out of sub-standard housing in thebarrios. Some of his smug foreign critics suggest Chavez effectively bought the votes of the poor – as though winning elections by delivering social justice is somehow bribery.

Alliances

That does not mean Chavez is beyond criticism. Venezuela was already a country with rampant crime when he came to power, but the situation has deteriorated since. Around 20,000 Venezuelans died at the hands of violent crime in 2011: an unacceptable death toll. As well as drugs, near-universal gun ownership and the destabilising impact of neighbouring Colombia, a weak (and often corrupt) police force is to blame. Although the government is beginning to roll out a national police force, endemic crime is a genuine crisis. When I spoke to Venezuelans in Caracas, the sometimes frightening lack of law-and-order was brought up by pro-Chavistas and opponents alike.

And then there is the matter of some of Chavez's unpleasant foreign associations. Although his closest allies were his fellow democratically elected left-of-centre governments in Latin America – nearly all of whom passionately defended Chavez from foreign criticism – he also supported brutal dictators in Iran, Libya and Syria. It has certainly sullied his reputation. Of course, we in the West can hardly single out Chavez for unsavoury alliances. We support and arm dictatorships such as Saudi Arabia; Britain's former Prime Minister Tony Blair is paid $13 million a year to work for Kazakhstan's dictatorship. But our own hypocrisy does not absolve Chavez of criticism.

The so-called Bolivarian Revolution was overly dependent on Chavez's own reputation, and inevitably his death raises questions about its future direction. But have no doubt: Chavez was a democratically elected champion of the poor. His policies lifted millions out of abject poverty and misery. He represented a break from years of corrupt regimes with often dire human rights records. His achievements were won in the face of an attempted military coup, an aggressively hostile media, and bitter foreign critics. He demonstrated that it is possible to resist the neo-liberal dogma that holds sway over much of humanity. He will be mourned by millions of Venezuelans – and understandably so.