WASHINGTON (Reuters) - Fannie Mae, the biggest source of money for U.S. home loans, on Tuesday said it needed a further $7.8 billion in federal aid to stay afloat as a shaky housing market widened its third-quarter loss to $5.1 billion.

The government-controlled firm also attributed the deeper cash drain to losses on derivatives used to hedge its exposure to interest-rate swings and on expenses related to home loans made prior to the 2008 financial collapse. In the year-earlier quarter it had a loss of a $1.3 billion.

Fannie Mae has now drawn $112.6 billion in bailout funds from the Treasury Departmentsince being seized by the government in 2008 as mortgage losses mounted, and it has returned $17.2 billion to taxpayers in the form of dividends.

"There is certainly a lot of pre-2009 loans that we need to work through and that is certainly driving the credit losses you saw in this quarter and over the last several years," Fannie Mae Chief Financial Officer Susan McFarland told Reuters.

She said the company was "working to reduce losses" on those legacy loans and "limit taxpayer exposure."

The mortgage finance company and its smaller rival Freddie Mac were taken over during the financial crisis as losses on subprime mortgages threatened insolvency.

Given the crucial role the two play in U.S. housing finance, owning or guaranteeing about half of all mortgages, the government has pledged unlimited funds to keep the firms afloat through the end of 2012. Combined, they have cost taxpayers around $169 billion.

The plan to put them into a government conservatorship was meant to be temporary, although it is likely to be years before a long-term replacement structure takes shape. Both the Obama administration and Congress want to eventually wind them down.

Their regulator estimates that the bailout could reach about $193 billion through 2014, with dividend payments taken into account.

Fannie Mae said credit losses, which include expenses related to the foreclosed properties it holds on its books as well as on its derivatives, increased in the third quarter to $4.5 billion from $3.9 billion in the second quarter.

Freddie Mac, the second-largest source of U.S. mortgage finance, said last week it lost $4.4 billion in the third quarter and needed to borrow an extra $6 billion from the federal government.

Fannie Mae has now reported losses in 16 of the last 17 quarters. It reported a profit of $73 million in the fourth quarter of last year, but that was largely attributed to a one-time payment from Bank of America.

Fannie Mae and Freddie Mac were created by Congress to encourage homeownership. They buy mortgages from lenders and repackage them as securities for investors, with a guarantee, to ensure a steady source of home loan funds.

The two firms, along with the Federal Housing Administration, now back about nine out of 10 new home loans.

(Reporting by Margaret Chadbourn; editing by Bob Burgdorfer)

Photo: Flickr user Images_of_Money.