FOR most of this century, Peru’s economy has shone: income per person has doubled in the past dozen years. But education failed to keep up. In 2012 Peru ranked last among the 65 countries that took part in the Programme for International Student Assessment (PISA), which tests the reading, maths and science proficiency of 15-year-olds.

Fortunately, Peru then found an outstanding education minister. Jaime Saavedra, an economist whose mother was a teacher, spent ten years at the World Bank, rising to be vice-president for poverty reduction. Appointed three years ago to the education portfolio, he was the only minister to keep his job when Pedro Pablo Kuczynski replaced Ollanta Humala as Peru’s president in July. He has generalised a previous pilot plan to link teachers’ pay to performance, overhauled teacher training and school management and begun a crash programme of repairing dilapidated school buildings. He has also championed a law passed in 2014, which for the first time subjected universities to minimum standards for probity and educational outcomes.

Mr Saavedra’s stewardship has brought results. Performance in national tests has risen sharply. The latest PISA figures, which were released on December 6th, confirmed this trend: Peru was the fastest improver in Latin America and the fourth-fastest in the world. Far from celebrating this achievement, the following day the opposition majority in Peru’s Congress subjected Mr Saavedra to an 11-hour interrogation, conducted with the manners of a playground bully. On December 15th it was due to vote to sack him.

The ostensible reasons were a delay in preparations for the Pan-American games to be held in Lima in 2019 (the education ministry handles sport) and alleged corruption in the purchase of computers by the ministry. Mr Saavedra convincingly denied knowledge of these problems and responsibility for them. So why is Popular Force, the main opposition party, so hostile to him? Many commentators ascribe this to the links several of its legislators have to universities that are lucrative businesses but offer poor value to students and face new scrutiny under the law regulating them (though that also applies to some pro-government lawmakers).

The congressional hearing was remarkable for its mixture of ignorance and bad faith. One legislator claimed that the PISA tests, which are organised by the OECD, a club of mainly rich countries, were a “smokescreen” and a “business” paid for by Mr Saavedra’s ministry. Others said the PISA tests were “adulterated” or an exercise in psychological warfare. This is bosh: even the harshest serious critics of PISA accept that it is properly conducted.

The censure of his best minister on such spurious grounds is a frontal challenge to Mr Kuczynski, less than five months after he took office. It lays bare the weakness of his mandate. He beat Keiko Fujimori, Popular Force’s leader, by just 50,000 votes out of 18m, after her campaign was hit by a last-minute scandal. Her surprise defeat stung; she has not talked to Mr Kuczynski since the election. He only reached the run-off after two other candidates were disqualified on questionable grounds. His party has just 17 of the 130 seats in Congress, while Popular Force has 72.

Mr Kuczynski could have turned Mr Saavedra’s future into an issue of confidence in the cabinet as a whole. Lose two such votes, and Peru’s constitution gives the president the right to dissolve Congress and call a fresh legislative election. But this has never been tested, and Popular Force hinted that it would hit back by declaring the presidency vacant. On December 13th Mr Kuczynski announced that he had rejected this course, calling for dialogue with the opposition. He could seek a coalition with Popular Force, inviting them to take cabinet posts. But that would appal many of his own supporters, who voted for him purely to stop Ms Fujimori, whose father controversially ruled Peru as an autocrat in the 1990s and is serving jail sentences for corruption. The alternative may be to submit to years of harassment from Congress by an opposition intent on showing its power.

As for Mr Saavedra, his likely departure illustrates the vicious circle that makes sustaining good policies so difficult in Latin American democracies. Popular Force has too many chancers who see a state that long failed to provide proper public services as a vein to be mined for private profit. That the party represents so many Peruvians is in part an indictment of the country’s educational backwardness. Better education is no guarantee of a better-quality democracy, but it certainly helps. And it is essential if Peru is ever to grow truly prosperous.