VENEZUELA’S president, Nicolás Maduro, admits that a parliamentary election on December 6th “could be the most difficult” test the government has faced since Hugo Chávez, his mentor, came to power following an election in 1998. Mr Maduro, like Chávez, claims to be leading an “anti-imperialist” revolution. Yet his legitimacy derives purely from the ballot box. Chávez’s popularity was boosted by an oil windfall, which he showered on Venezuela’s previously neglected poor. This helped him win a further three elections, by wide margins, before his death from cancer in 2013. Shortly afterwards Mr Maduro won by just 1.5 percentage points a presidential election that the opposition denounced as fraudulent.

Mr Maduro, a former bus driver, lacks not just Chávez’s charisma and political skills but also his luck. The plunge in the oil price, plus years of corrupt mismanagement, have hit Venezuela hard. The government stopped publishing economic statistics months ago. The IMF forecasts that inflation will hit 190% and the economy will shrink by 10% this year (after a decline of 4% last year). Imports have fallen by more than 40% since 2012, reckons Francisco Rodríguez, a Venezuelan economist at Bank of America. Despite big price increases, many goods are in short supply. “People are really sick of having to queue up for everything,” says a long-suffering resident of Caracas.

Discontent has brought an unprecedented collapse in support for chavismo. According to Datanalisis, a pollster that accurately forecast Chávez’s victories, Mr Maduro’s approval rating is down to 22% and the opposition leads the ruling United Socialist Party (PSUV) and its allies by 28 percentage points.

Mr Maduro repeats that the “revolution” will win como sea—“by hook or by crook”. The government has gerrymandered voting districts to give more seats to rural areas where the PSUV is strong: six urban states with 52% of the electorate will elect just 64 deputies; the remaining 18 will elect 100. In September, after smugglers clashed with the army, Mr Maduro declared a “state of exception” along the border with Colombia. In those areas, which will elect 19 legislators, campaigning is restricted, which hurts the opposition.

The government has refused to allow election observers from the Organisation of American States (OAS) or the European Union. A mission of “electoral accompaniment” of the Union of South American Nations has been thrown into doubt after Venezuela rejected Brazil’s representative. In an unprecedented 18-page letter to Venezuela’s electoral authority, released on November 10th, Luis Almagro, the OAS’s secretary-general, paints a devastating picture of the tilted field on which the opposition must play. Mr Almagro, formerly a politician of Uruguay’s left-wing Broad Front, warns that the opposition lacks “equitable” conditions and that the ruling party abuses the resources of the state.

Seven opposition leaders are banned from being candidates. One, Leopoldo López, is in jail (sentenced to almost 14 years for inciting violence), the first such case in Latin America since Uruguay’s military dictatorship locked up an opposition leader during an election in 1984, Mr Almagro points out. Last month, one of the two lead prosecutors in the case fled to Miami and said the evidence against Mr López was fabricated. The electoral authority has placed next to the opposition coalition on the electronic ballot a pro-regime splinter party with a similar name and logo. In one state, a candidate from that party has the same name as an opposition leader. The government has crippled the opposition media, for example by not renewing broadcasting licences.

The regime’s propaganda is aimed at manufacturing threats and generating fear. It blames Venezuela’s woes on an “economic war” engineered by the opposition and the United States. On November 10th two nephews of Mr Maduro’s wife were arrested in Haiti to face drug-trafficking charges in the United States, which will fan conspiracy theories.

As the opposition surges in the polls, some analysts in Caracas think that it could win the three-fifths majority in the legislative assembly required to claw back powers from Mr Maduro. The government tacitly recognises the possibility of defeat: it recently pressured 13 supreme court justices to retire early, so that they can be replaced before the new assembly convenes in January.

Mr Maduro talks darkly of “governing with the people” if he loses. This suggests that he would seek to throttle and bypass the assembly. But everything indicates that “the people” are no longer with him. If he blocks peaceful change, he may ensure that frustration leads to violence.