“EVERYONE'S pencil should be on the apple in the tally-mark chart!” shouts a teacher to a class of pupils at Harvest Preparatory School in Minneapolis. Papers and feet are shuffled; a test is coming. Each class is examined every six or seven weeks. The teachers are monitored too. As a result, Harvest Prep outperformed every city school district in Minnesota in maths last year. It is also a “charter” school; and all the children are black.

Twenty years ago Minnesota became the first American state to pass charter-school laws. (Charter schools are publicly funded but independently managed.) The idea was born of frustration with traditional publicly funded schools and the persistent achievement gap between poor minority pupils and those from middle-income homes. Charters enroll more poor, black and Latino pupils, and more pupils who at first do less well at standardised tests, than their traditional counterparts.

Today there are 5,600 charter schools, and they serve more than 2m pupils in 41 of America's 50 states. This number has grown annually by 7.5% since 2006 (see chart), but is still tiny: charters enroll less than 4% of the country's public-school students. Some places have taken to charter schools particularly enthusiastically: in Washington, DC, 44% of public-school students attend a charter school.

That figure is dwarfed by New Orleans. There two-thirds of students are in charters, thanks to an overhaul of the city's disastrous schools after Hurricane Katrina in 2005. Today half of charter schools in the city are improving reading or maths at a significantly faster rate than competing public schools; and across the state as a whole charters are performing better.

Parents like charter schools, and waiting-lists for them are growing faster than new places. Nina Rees, the new head of the National Alliance for Public Charter Schools, says more than 600,000 children are on waiting lists. Oversubscribed schools choose pupils by lottery, something poignantly illustrated in the documentary film “Waiting for Superman”.

Although charter schools have won support from across the political spectrum, they have always attracted controversy. Much of the unease has been stirred up by teachers' unions; charter schools do not usually employ unionised teachers. As recounted in a new book, “Zero Chance of Passage”, by Ember Reichgott Junge, a former Minnesota legislator who wrote the original charter legislation, unions have from the outset pushed the misleading idea that charters drain resources from traditional schools. They also maintain that politicians who support them are against public education. That is not true. Critics of charter schools derive more ammunition from the fact that their performance varies widely. For example, earlier this year the University of Minnesota found that charters in the twin cities of Minneapolis-St Paul lagged behind public elementary schools, ranking 7.5% lower for maths and 4.4% lower for reading. Hundreds of other studies have been done on charters; but most are of dubious quality. One recent analysis had to discard 75% of its research because it had failed to account for differences between the backgrounds and academic histories of pupils attending the schools. Much political capital has been made of a 2009 study of 16 states that found that only 17% of charter schools were better than public schools, 37% were worse and the rest were about the same. The work was done by the Centre for Research on Education Outcomes (Credo) at Stanford University. The Credo study has been criticised for not comparing the results of children who have won charter-school lotteries with those who have not—a natural experiment in which the only difference between winners and losers should be the schooling they receive. Such studies suggest that charters are better. For example, a lottery study in New York City found that by eighth grade (around 13), charter-school pupils were 30 points ahead in maths.

However, recent work by Mathematica, an independent policy group, suggests that the Credo study is sound. The bigger problem is that its findings have been misinterpreted. First, the children who most need charters have been served well. Credo finds that students in poverty and English language learners fare better in charters. And a national “meta-analysis” of research, done last year for the Centre on Reinventing Public Education in Seattle, found charters were better at teaching elementary-school reading and mathematics, and middle-school mathematics. High-school charters, though, fared worse. Another recent study in Massachusetts for the National Bureau of Economic Research concluded that urban charter schools are shown to be effective for minorities, poor students and low achievers.

Second, charter school performance is not so “mixed” if you look at the data on a state-by-state basis, rather than across the country as a whole. States with reading and maths gains that were significantly higher for charter-school students than in traditional schools included Arkansas, Colorado (Denver), Illinois (Chicago), Louisiana and Missouri.

Credo thinks that the variation in quality can be traced to the governing legislation behind the schools. Margaret Raymond, director of Credo, points to Arizona's terrible results in 2009, which were the result of lax screening of those who were allowed to set up charter schools, and no serious reviews thereafter. Ohio, where most charters are worse than the traditional schools, gained a reputation as the “Wild West” of charter schools because it exercised almost no oversight.

Massachusetts, meanwhile, has had excellent results and is strict about the schools it allows to operate; the state will step in and close an underperforming school at short notice. Caps on the number of charters in a state drag down performance as much as lax oversight, because they cramp the diversification of the market and discourage investment. Bad laws make bad charter schools.

Ms Raymond says traditional public schools no longer have the excuse that they cannot be blamed for the poor performance of children because of their background; so competition from charters may improve standards in non-charters, too.

Moreover, if charter schools go downhill they can usually be closed more easily than traditional schools. Even so, most of those attending a big schools conference in Minneapolis in June agreed that more bad charters should close. Since 1993 15% of charter schools have shut their gates, most because of low enrolment, a sign that the market is working.

Charter schools have been successful because they offer freedom to shape the school to the pupils, rather than the other way round. Schools can change the length of the school day, fire bad teachers and spend their money as they wish. At Harvest Prep the school year is continuous, with short and relatively frequent bursts of holiday, because that keeps learning on track and kids out of trouble.

The charter-school concept has also attracted new institutions into early education, says Tim Knowles, director of the Urban Education Institute, which is part of the University of Chicago. The university operates four charters for (mostly) poor black children up to ninth grade (14-15), and college-acceptance rates for children going through them have been above 98% in each of the past three years. This compares with a city average of 35%.

Both Barack Obama and Mitt Romney favour charter schools, but at a time of probable cuts in federal education spending their growth may slow. Despite huge demand, and even though the ingredients for success are clear after two decades of experiment, extending charters' successes to the other 96% will take a long time.