The Treasury Department on Friday announced it would rework the terms of its bailout of mortgage giants Fannie Mae and Freddie Mac to make sure taxpayers benefit from any profits.

The government also affirmed its backing of the two firms, a move intended to assure the lending industry, which counts on Fannie and Freddie to finance the nation’s mortgage market.

“We are taking the next step toward responsibly winding down Fannie Mae and Freddie Mac, while continuing to support the necessary process of repair and recovery in the housing market,” Michael Stegman, a Treasury official who oversees housing finance policy, said in a statement.

The renegotiated terms of the four-year-old federal conservatorship require the firms to downsize the number of mortgages they hold on their books by 15 percent annually, up from 10 percent. The accelerated timetable would put such investment portfolios on track to reach the government’s target of $250 billion four years earlier than originally scheduled.

Even after this, the two firms would still guarantee trillions in mortgages until lawmakers agree on a way to wind down the firms altogether.

In addition, the revamped agreement alters the way in which Fannie and Freddie repay taxpayers. Previously, the firms were required to make a 10 percent dividend payment on their investments to the Treasury each quarter — even if that meant borrowing more from the government to cover the cost. Under the new arrangement, any profits that Fannie or Freddie make would go entirely to the government each quarter; the government would receive no payment if the firms do not turn a profit.

In recent months, Fannie and Freddie have seen their bottom lines improve markedly as the nation’s housing market has begun to recover. Last week, Fannie Mae reported a $5.1 billion second-quarter profit, which came on top of a $2.9 billion dividend the company paid to taxpayers. The company’s chief executive asserted at the time that Fannie “has strong potential earnings power that can deliver considerable value to taxpayers over the long term.”

In addition, Freddie recently reported a $3 billion profit in its most recent quarter, alongside a $1.8 billion dividend payment to taxpayers. Those profits also were attributable largely to the improving housing market.

Both companies noted in recent earnings reports that they did not need taxpayer assistance for the second quarter, which ended June 30.

District-based Fannie and McLean-based Freddie have long played central roles in the nation’s housing market and the overall economy. But they have been particularly vital in keeping the country’s mortgage markets functioning in the wake of the financial crisis. The firms back more than half of all U.S. mortgages.

Fannie and Freddie were seized by the government in September 2008 and placed into conservatorship. They owe taxpayers nearly $150 billion.

What to do with the two firms has remained a source of fierce debate in Washington. The Obama administration and congressional Republicans have agreed that the companies should be eliminated over time. But policymakers have yet to agree on the specifics of how to accomplish that.

Obama has proposed two approaches, one in which the government would form smaller entities to help bolster mortgage markets, another in which the government would rely on the private market to fill the role played by Fannie and Freddie.

Republicans on Capitol Hill, meanwhile, have offered proposals to simply wind down the two companies as soon as possible, and they were quick to criticize Friday’s announcement.

Rep. Spencer Bachus (R-Ala.), chairman of the House Financial Services Committee, said in a statement that the move would make it “less likely” that taxpayers will be paid back and that the altered bailout “blunts efforts to reform Fannie and Freddie by fostering the false impression they are healthy institutions that should be restored to their previous status.”

Groups such as the American Bankers Association and the Mortgage Bankers Association applauded the move, saying it appropriately scales back the government’s stake in Fannie and Freddie while also making sure that, for now, they can continue to play a key role in keeping the mortgage markets functioning smoothly.

Edward J. DeMarco, acting director of the Federal Housing Finance Agency, which oversees Fannie and Freddie, praised the reworked agreements Friday.

“These changes provide certainty to Fannie Mae, Freddie Mac and market participants as they continue to perform their critical mission of providing liquidity and stability to the country’s housing market,” DeMarco said in a statement.