This is the fifth quarter in which Freddie hasn't requested new federal aid since it was taken over in September 2008.
Freddie Mac requested $19 million in federal aid in the first quarter. The company received $7.6 billion for all of 2011 and $13 billion for all of 2010.
McLean, Va.-based Freddie Mac said Tuesday that its net income attributable to common shareholders amounted to 37 cents per share in the April-June period. That compares with a loss of $3.76 billion, or $1.16 per share, in the same period a year ago.
It was Freddie's first profitable quarter since the first quarter of 2011.
Freddie's latest results take into account $1.8 billion in dividend payments that Freddie made to the government, its primary shareholder. The company said the gain reflected a decrease in the amounts that it had to set aside to cover potential losses on mortgages as the housing market has improved.
Fannie and Freddie are required to pay 10 percent dividends on the government money they receive.
Freddie has paid more to the government in dividends than it has taken in aid in the last six quarters, the company says.
Twenty-eight percent of the company's holdings are home loans issued between 2005 and 2008, which accounted for 88 percent of its losses in the first six months of the year.
Freddie said those loans are becoming a smaller proportion of its portfolio, and that over time that should have a positive impact on its finances.
Freddie and Washington-based Fannie own or guarantee about half of all U.S. mortgages, or nearly 31 million home loans, which 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 has slowly begun to improve, but has a long way to go before it's healthy. Many homeowners are still defaulting on their mortgages. Unemployment remains high at 8.3 percent.
Fannie and Freddie buy home loans from banks and other lenders, package them into bonds with a guarantee against default, and then sell them to investors around the world. When property values drop, more homeowners default, either because they are unable to afford the payments or because they owe more than the property is worth. Because of the guarantees, Fannie and Freddie must cover the losses.
Pressure continues on the government to eliminate Fannie and Freddie and reduce taxpayers' exposure to risk. The Treasury Department put forward a plan last year to slowly dissolve the companies, though that process could take years. Abolishing Fannie and Freddie would transform how homes are bought and redefine who can afford them.