Fannie Mae says Mayopoulos, 53, will become president and chief executive officer on June 18.
He replaces Michael J. Williams, who announced in January that he would step down after a successor was found.
The government rescued Fannie and smaller sibling Freddie Mac in September 2008 after the two companies absorbed huge losses on risky mortgages that threatened to topple them.
Since then, a federal regulator has controlled the two companies' financial decisions.
So far, Fannie and Freddie have cost taxpayers about $170 billion — the largest bailout of the financial crisis.