Rep. John Kline (R-Minn.) was the lead sponsor of the House bill to rewrite No Child Left Behind. (Evan Vucci/AP)

The House voted Wednesday to rewrite No Child Left Behind, the nation’s main education law, passing legislation that would significantly scale back the federal government’s role in public education and hand more power back to the states.

No Democrats voted for the legislation, which passed by a vote of 218 to 213. More than two dozen Republicans joined the Democrats in their opposition.

Many Republicans hailed the legislation’s passage as a victory for local control, while Democrats feared that it would return the nation to the days before No Child Left Behind, when many states masked achievement gaps between affluent and poor students, English learners or the disabled.

The House GOP bill, which also would change how federal funds are dispensed to educate poor students, sets up the far-right boundary for negotiations with the Senate, which is working its way through its own bill, one written with bipartisan support.

Passage was a win for the Republican leadership, which corralled conservative members of its caucus who had threatened to defect because they thought that the bill did not go far enough to reduce the federal role in education.

President Obama has threatened to veto the House bill, called the Student Success Act.

No Child Left Behind, which is widely regarded as an unworkable and overly punitive law, expired in 2007 but has remained in effect. Congress has been unable to agree on how to revise it.

Like the current law, the House legislation would require states to give annual math and reading tests to students in grades 3 through 8 and once in high school. States also would have to continue publishing data showing how groups of students — including African Americans, Latinos, poor children and those with disabilities — perform.

But in an important departure from current law, the bill includes an amendment that allows parents to opt their children out of standardized tests without putting school districts at risk of federal sanctions.

That provision is a response to complaints about overtesting, said Rep. Matt Salmon (R-Ariz.), who introduced the amendment. It passed 251 to 178, with 19 Democrats voting for it.

“Because of this frenzied obsession with high-stakes testing, more and more time is being usurped from actual classroom learning,” Salmon said.

Democrats said the opt-out measure would gut the law’s civil rights protections, giving administrators a loophole to discourage low performers to stay home on exam day, something that could skew performance results and hide racial or socioeconomic inequities. Current law requires school districts to ensure that 95 percent of children take the exams.

“If you’re not measuring the achievement gap, you can’t deal with the achievement gap,” said Rep. Bobby Scott (D-Va.).

The bill would largely let states determine how to spend federal dollars, and states would not be required to meet federal benchmarks of academic progress. States would have to intervene in schools that are not improving by their measures, but the type of intervention and the number of schools would be up to the states.

One of the most contested aspects of the bill would change how federal funds are allocated to help educate poor students.

Public schools now receive those federal funds according to a formula based on the number of disadvantaged students enrolled. Under the Republican plan, known as “Title 1 portability,” the money would “follow the child” — if a poor student transferred from a high-poverty school to a wealthier one, the federal money would follow the student to the new school.

Democrats argue that the bill would send dollars out of the neediest schools to more affluent ones. The Senate’s bill does not include Title I portability.

Conservative groups including Heritage Action, FreedomWorks and the American Principles Project were opposed to the House bill because it would not reduce the federal role in education enough.

They supported an amendment that would have allowed states to opt out of almost all federal requirements, except for civil rights laws, without losing federal funding. That amendment was defeated.

Mike DeBonis contributed to this report.