The House approved a Republican proposal Thursday to allow interest rates on federal student loans to rise or fall from year to year with the government’s cost of borrowing, ending a system in which rates are fixed by law.

The proposal cleared the GOP-led House on a largely party-line vote of 221 to 198, but it faces opposition in the Democratic-controlled Senate and a veto threat from President Obama.

The legislation responds to a looming deadline: On July 1, unless the law is changed, rates for a certain type of new loan for undergraduate students in financial need will double to 6.8 percent, from 3.4 percent.

Last year, facing a similar rate-doubling deadline during his reelection campaign, Obama pushed Congress to freeze the 3.4 percent rate for one year. Mitt Romney, his Republican opponent, agreed. Now there is increasing talk of changing the loan system to avoid politicizing rates.

In some respects, the Republican bill echoes a plan Obama offered in April to tie interest rates to the yield on the 10-year Treasury bill, rather than setting them via an act of Congress.

“The market is a much more reliable determiner of the true cost of capital than a bunch of us sitting around taking a guess,” said Rep. John Kline (R-Minn.), sponsor of the bill and chairman of the Education and the Workforce Committee.

Although rates under Obama’s plan would vary from year to year, they would be fixed after students take out a loan. The Republican bill would let rates for individual loans float. The administration cited that and other differences as it issued a veto threat Wednesday.

“A rate that continues to vary after the loan has already been taken out would create uncertainty and lessen transparency for students and their families who are making decisions about borrowing for college,” the administration said in a statement.

Rep. Jared Polis (Colo.), one of four Democrats who broke party ranks to support the bill, called it “a step in the right direction toward the president’s proposal.”

Eight Republicans voted against the measure.

Rep. George Miller (Calif.), the education committee’s ranking Democrat, said he opposed the bill because annual variable rates would “create a huge amount of uncertainty for students and families thinking about financing their education.”

Miller and other senior congressional Democrats favor a two-year extension of the 3.4 percent rate for what are known as subsidized Stafford loans.

Because market rates are now low, the initial rate for those loans would be significantly lower than 6.8 percent under either the Republican bill or the Obama plan. Such loans are a cornerstone of financial planning for several million college students in financial need. The subsidy means that interest on loans does not accrue until after graduation.

Rates for unsubsidized Staf­ford loans, as well as certain loans available to graduate students and parents, also would be affected by the legislation. However, rates on those loans are not scheduled to double July 1.

Under the Republican bill, rates for all Stafford loans, subsidized or not, would be set at that of the 10-year Treasury note, plus 2.5 percentage points, and capped at 8.5 percent. Initial rates this year would be forecast to settle at about 4.4 percent.

The bill also would peg rates on graduate student and parent loans to the 10-year T-bill, plus 4.5 percentage points, capped at 10.5 percent.

The Congressional Budget Office found that the Republican bill would save the government $1 billion over five years and $3.7 billion over a decade.

Obama’s proposal does not include rate caps — angering some student advocacy groups — but does include federal funding to help defray repayment costs for college graduates based on their income. The CBO found that the president’s plan, counting the income-based repayment initiative, would cost $33.4 billion over five years but save the government $3.1 billion over a decade.