President Obama signed a new K-12 education law on Thursday that effectively ends heavy federal involvement in public schools and sends much of that authority back to states and local school districts.

“I want this not just because it’s good for the students themselves, the communities involved and it’s good for our economy but because it really goes to the essence of what we are about as Americans,” Obama said at a White House signing ceremony. “There is nothing more essential to living up to the ideals of this nation than to make sure every child is able to live up to their God given potential.”

The Every Student Succeeds Act, which received strong bipartisan support from both houses of Congress, will directly affect nearly 50 million students and their 3.4 million teachers in the nation’s 100,000 public schools.

The law sailed through both houses of Congress this month with strong bipartisan support, a fact made more remarkable because Republicans and Democrats had been wrangling over the subject for eight years, unable to reach agreement about the proper balance between federalism and accountability.

But Sen. Lamar Alexander (R-Tenn.), chairman of the Senate education panel, and the ranking Democrat, Sen. Patty Murray (Wash.), worked with their House counterparts, Rep. John Kline (R-Minn.) and Rep. Robert C. “Bobby” Scott (D-Va.), to get the deal done.

“This is a Christmas miracle,” Obama said. “A bipartisan bill signing right here!”

“It’s not as if there weren’t some significant ideological differences on some of these issues,” the president said, to knowing laughter from the crowd of teachers, state officials, business groups, union leaders, civil rights advocates and lawmakers gathered for the bill signing. “People did not agree to everything on outset but they were willing to listen to each other in a civil, constructive way. It’s a testament to the four leaders of the respective committees that they set that kind of tone. It’s something we don’t often see here in Washington.”

The measure replaces No Child Left Behind, the 2002 law that amplified Washington’s role in U.S. classrooms and launched a national system that judged schools based on math and reading test scores and required them to raise scores every year or face escalating penalties. No Child Left Behind was also created with strong bipartisan support, but over time its test-based accountability became widely seen as overly punitive and unrealistic.

“The goals of No Child Left Behind were the right ones — high standards, accountability, closing the achievement gap, making sure every child was learning,” Obama said. “But in practice, it often fell short. . . . It led to too much testing during classroom time, forced schools and school districts into cookie cutter reforms that didn’t produce the kind of results that we wanted to see.”

The new law erases that system and instead lets each state develop its own methods for judging school quality.

States will still be required to test students annually in math and reading in grades three through eight and once in high school and to publicly report the scores according to race, income, ethnicity, disability and whether students are English-language learners.

But states will decide what to do about the most troubled schools, those where test scores are in the lowest 5 percent, achievement gaps between groups of students are greatest, or where fewer than two-thirds of students graduate on time.

And states will decide how to weigh test scores and whether or how to evaluate teachers. They will be allowed to consider other factors, such as whether a school offers challenging courses or the degree of parent involvement. They will set their own goals and timelines for academic progress, though their plans must be approved by the federal Department of Education.

The new law also dismantles a second federal accountability system the Obama administration created, in which states were excused from the demands of No Child Left Behind if they adopted the administration’s favored policies. Forty-three states and the District hold those waivers today; they will be moot by August.

It is unclear whether states will retain those policies absent a federal mandate. And now, the political battles over thorny issues such as testing, academic standards and the best way to ensure quality teachers will migrate from Washington to 50 state capitals, observers say.

“Now the hard work begins,” Obama said. “Laws are only as good as the implementation.”

The new law significantly reduces the legal authority of the education secretary, who is now legally barred from influencing state decisions about academic benchmarks, such as the Common Core State Standards, teacher evaluations and other policies.

That aspect of the law is widely seen as a rebuttal to Education Secretary Arne Duncan’s assertive use of executive power, behavior that made him one of the most influential education secretaries in U.S. history but earned him criticism from Alexander and other Republicans, who said he acted as a “national school superintendent.”

But at the signing, Obama praised Duncan, a close personal friend and one of his longest serving Cabinet members, who is stepping down at the end of this month.

Duncan’s work was vital to laying the groundwork for the new law, the president said. “Arne has dedicated his life to the cause of education and sometimes, in the nicest possible way, he’s gotten on people’s nerves because he pushed them and prodded them,” Obama said, as Duncan stood steps away. “Had he not been as tenacious as he was, I don’t believe we would have as good a product as we have here today.”