Ally Financial Inc, the former General Motors Acceptance Corp, posted lower quarterly profit, hurt by bad mortgages made before the housing crisis.

Ally said it earned $146 million in the first quarter compared with $162 million a year earlier when it was still known as GMAC.

The company lost $39 million in its legacy mortgage portfolio, before taxes, compared with an $85 million gain in the same quarter last year.

We expect profitability to improve over time, said Michael Carpenter, chief executive, citing falling costs for funding and a better mix of loans.

Reducing its funding costs, Ally grew its deposit base to $40.7 billion from $39 billion at the end of December and $32.9 billion a year ago. The company booked $14.3 billion in new consumer loans, a 75 percent increase from the same quarter a year ago, according to the statement.

Ally, majority-owned by the U.S. government, on March 31 filed a prospectus for an initial public offering, to allow the U.S. Treasury to begin selling its 73.8 percent stake in the company.

Taxpayers injected more than $17 billion into Ally in bailouts in 2008 and 2009 after it lost money on mortgages. The company is known for its heavily-advertised brand name ditech.com.

Ally had more than $172 billion of assets at the end of December, making it the 16th-largest U.S. bank holding company, according to research service SNL Financial.

(Editing by Dave Zimmerman)