Wells Fargo & Co. has agreed to pay $591 million to Fannie Mae to release it from liabilities for problem mortgages it made before 2009.

The repurchase agreement, announced Friday, closes Fannie Mae's reviews of the individual home loans it bought from private lenders during the housing boom as it sought reimbursement for loans with "underwriting defects."

The San Francisco-based bank said it will make a one-time cash payment to Fannie Mae of $541 million out of money it has in reserves. There won't be any further expense for it in the current quarter, it said.

Fannie Mae said the bank still will be obligated "for certain other contractual responsibilities" under the resolution agreement, but declined to elaborate.

Wells Fargo cut a similar deal in September with Freddie Mac for $869 million over repurchasing problem home loans.

This latest accord with Wells Fargo is the last of at least eight mortgage repurchase agreements Fannie Mae struck this year with major banks, the largest of which was with Bank of America for $10.3 billion.

The $591 million settlement with Wells Fargo is separate from one revealed in November. In that one, Wells Fargo paid $335 million to the Federal Housing Finance Agency, which regulates Fannie Mae and ­Freddie Mac, to settle claims that the bank misled Fannie Mae and Freddie Mac about mortgage-backed securities (as opposed to individual home loans) they purchased in the go-go years before the housing collapse.

Fannie Mae and Freddie Mac are the mortgage finance giants that were bailed out by taxpayers in 2008 as mortgage defaults rose. Under the stewardship of the U.S. government, the companies continue to dominate the nation's housing market as they buy up loans and bundle them for resale to investors.

The two companies pay most of their profits to the U.S. Treasury. To date, they have paid out nearly as much, about $188 billion, as the government sank into them to keep them solvent.

Jennifer Bjorhus • 612-673-4683