The gain "was driven by favorable market conditions, including the continued improvement in the housing market," Freddie CEO Donald Layton said in a statement.
The government rescued Freddie and larger sibling Fannie Mae during the 2008 financial crisis after both incurred massive losses on risky mortgages. Taxpayers have spent about $170 billion to rescue them, the costliest bailout of the 2008 financial crisis.
Under a new federal policy announced last summer, Fannie and Freddie have to turn over all profits they earn every quarter to the government. The change was made to ensure the companies pay the government back.
Freddie requested no government aid in the second quarter, after asking for $19 million in the first quarter. The company received $7.6 billion for all of 2011 and $13 billion for all of 2010.
Fannie and Freddie are required to pay 10 percent dividends on the government money they receive.
Freddie, based in McLean, Va., has paid more to the government in dividends than it has taken in aid over the last seven quarters, the company says.
Freddie and Washington-based Fannie own or guarantee about half of all U.S. mortgages, or nearly 31 million home loans. Those loans are worth more than $5 trillion. Along with other federal agencies, they backed nearly 90 percent of new mortgages over the past year.
The housing market is finally starting to recover more than five years after the bubble burst. Home sales are up from a year ago, helped by a limited supply and record-low mortgage rates. Builders are more confident and have started to construct more homes. And home prices are showing consistent gains.
A report Tuesday by CoreLogic showed that a measure of U.S. home prices jumped 5 percent in September compared with a year earlier. It was the largest year-over-year increase since July 2006.