A bipartisan bill to reduce student loan interest rates for millions across the U.S. is headed to President Obama for signature after it was approved by the House Wednesday night.

The legislation, which was passed by the Senate last week, links student loan interest rates to the financial markets. It offers lower rates for most students now, but higher ones down the line if the economy improves as expected.

"Going forward, the whims of Washington politicians won't dictate student loan interest rates, meaning more certainty and more opportunities for students to take advantage of lower rates," House Speaker John Boehner said.

The measure passed 392-31.

"This is a win for students and taxpayers," said Rep. John Kline, the Republican chairman of the House Committee on Education and the Workforce.

The top Democrat on that committee joined Kline on the House floor to urge colleagues to back the bill.

"It saves students and families money," said Rep. George Miller, D-Calif.

Undergraduates this fall would borrow at a 3.9 percent interest rate for subsidized and unsubsidized loans. Graduate students would have access to loans at 5.4 percent, and parents would borrow at 6.4 percent. The rates would be locked in for that year's loan, but each year's loan could be more expensive than the last. Rates would rise as the economy picks up and it becomes more expensive for the government to borrow money.

But for now, interest payments for tuition, housing and books would be less expensive under the House-passed bill.

The House earlier this year passed legislation that is similar to what the Senate later passed. Both versions link interest rates to 10-year Treasury notes and remove Congress' annual role in determining rates.

"Campaign promises and political posturing should not play a role in the setting of student loan interest rates," said Rep. Virginia Foxx, R-N.C. "Borrowers deserve better."

Negotiators of the Senate compromise were mindful of the House-passed version, as well as the White House preference to shift responsibility for interest rates to the financial markets. The resulting bipartisan bill passed the Senate 81-18.

With changes made in the Senate -- most notably a cap on how interest rates could climb and locking in interest rates for the life of each year's loan -- Democrats dropped their objections and joined Republicans in backing the bill.

Interest rates would not top 8.25 percent for undergraduates. Graduate students would not pay rates higher than 9.5 percent, and parents' rates would top out at 10.5 percent. Using Congressional Budget Office estimates, rates would not reach those limits in the next 10 years.

The White House has endorsed the deal, despite objections from consumer advocates that the proposal could cost future students.

"The bottom line is that students will pay more under this bill than if Congress did nothing, and low rates will soon give way to rates that are even higher than the 6.8 percent rate that Congress is trying to avoid," said Chris Lindstrom, higher education program director for the consumer group US PIRG.

Rates on new subsidized Stafford loans doubled to 6.8 percent July 1 because Congress could not agree on a way to keep them at 3.4 percent. Without congressional action, rates would stay at 6.8 percent -- a reality most lawmakers called unacceptable.

The compromise that came together during the last month would be a good deal for all students through the 2015 academic year. After that, interest rates are expected to climb above where they were when students left campus in the spring, if congressional estimates prove correct.

The White House and its allies said the new loan structure would offer lower rates to 11 million borrowers right away and save the average undergraduate $1,500 in interest charges.

"Finally, we are taking action on the pressing issue of college affordability," said Rep. Jared Polis, D-Colo. "We have to make sure our students are able to plan their futures."

Lawmakers were already talking about changing the deal when they take up a rewrite of the Higher Education Act this fall. As a condition of his support, Senate Health, Education, Labor and Pensions Committee Chairman Tom Harkin won a Government Accountability Office report on the costs of colleges. That document was expected to guide an overhaul of the deal just negotiated.

"We will have the ability to come back and look," said Rep. Sheila Jackson Lee, D-Texas.

The Congressional Budget Office estimated the bill would reduce the deficit by $715 million over the next decade. During that same time, federal loans would be a $1.4 trillion program.

The Associated Press contributed to this report