GMAC Financial Services, a lender majority-owned by the U.S. government, posted its first profit since the fourth quarter of 2008 as it starts to recover from billions of dollars lost on bad mortgages.

GMAC, one of the largest car loan companies in the United States, said the profit was a key milestone in its recovery from the losses that drove it to seek multiple government bailouts.

As part of that turnaround, GMAC will change its name to Ally Financial Inc on May 10. GMAC was formerly owned by General Motors Co , which owns the trademark on its current name.

The right to use that trademark expires in 2016. GMAC is replacing it with the Ally name that it first introduced for its bank in May 2009.

GMAC said its turnaround was based on significantly reduced loan loss provisions, stabilizing auto credit trends, and continuing efforts to reduce the bad mortgage assets on its books.

The company's first-quarter profit of $162 million compared with a net loss of $675 million a year earlier.

GMAC also said it had been able to access the capital markets for the first time since 2007. It has issued more than $5 billion of global unsecured debt so far this year.

The U.S. government holds a 56.3 percent stake in GMAC as a result of three separate capital infusions totaling more than $17 billion, including a $3.8 billion investment on December 30.

GMAC Chief Executive Michael Carpenter said the company was continuing to work on repaying the government.

We're going back down to Treasury to have exactly that conversation tomorrow, he said in response to an analyst's question during a conference call.

GMAC is considering elements that may include an IPO (that) will allow us to repay Treasury in a reasonable amount of time, he said.

GMAC lost $5 billion in the fourth quarter of 2009 on home loans, and assured investors at the end of last year that the worst was over. Home loans fueled GMAC's growth earlier this decade, but have since triggered billions of dollars of losses for the company.

GMAC's troubled mortgage unit, Residential Capital, made a net profit of $110 million in the first quarter. Carpenter would not discuss specific plans for ResCap except to say that a potential sale depended on market opportunities.

If there's an attractive transaction, we'll go in that direction, he said in response to an analyst's question.

The company denied reports last month that it was struggling to sell the main ResCap unit, which could lead to another bailout.

But GMAC is having success dismantling some parts of the unit. The company said last month that ResCap had agreed to sell its European mortgage assets and businesses to affiliates of hedge fund and private equity firm Fortress Investment Group .

(Reporting by Maria Aspan, editing by Gerald E. McCormick, Maureen Bavdek and John Wallace)