A housing recovery that began last year has made both profitable again. Combined, they have paid back roughly $136 billion of their government loans. Those payments are helping to make this year’s federal budget deficit the smallest since President Obama took office.

Once the second-quarter dividend is paid, Freddie will have repaid $41.4 billion of the roughly $71.3 billion it received from taxpayers.

Fannie and Freddie own or guarantee about half of all mortgages in the United States, worth about $5 trillion. Along with other federal agencies, they back about 90 percent of new mortgages.

On Tuesday, Mr. Obama proposed a broad overhaul of the American mortgage finance system, including winding down Fannie and Freddie. He declared that taxpayers should never again be left “holding the bag” for the mortgage giants’ risky moves.

Nearly all of Freddie’s second-quarter profit is going back to the government. Under a federal policy adopted last year, Fannie and Freddie must turn over their entire net worth exceeding $3 billion in each quarter to the Treasury. Freddie said its net worth in the second quarter was $7.4 billion.