Timothy Mayopoulos, Fannie Mae's president and chief executive, is leaving the company at the end of the year. (Patrick T. Fallon/Bloomberg News)

Fannie Mae announced that chief executive Timothy Mayopoulos is stepping down at the end of the year, setting up the firm for new leadership at a time when the Trump administration could introduce sweeping change for the mortgage firm.

Mayopoulos, who led the mortgage financing firm to financial stability after the housing crash, ran the company for six years. Fannie Mae said its board of directors is searching for a new leader. The company did not say what Mayopoulos will do next.

Mayopoulos joined Fannie as general counsel in 2009, when it was still reeling from the losses it faced during the Great Recession. He oversaw the company as the housing market recovered and Fannie Mae paid back the billions of dollars that it received in bailouts from the federal government.

“During Tim’s tenure as CEO, Fannie Mae has been profitable on an annual basis, paid the Treasury approximately $167 billion in dividends and reduced risk to taxpayers," Egbert L.J. Perry, the chairman of Fannie Mae’s board of directors, said in a statement.

Fannie Mae’s next leader will need to run the company at a time when lawmakers, industry groups and the federal government are proposing ways to restructure Fannie Mae and Freddie Mac, two government-backed entities that insure U.S. mortgages and have been under government conservatorship since the downturn.

The guarantee that Fannie and Freddie provide on mortgages has helped to boost liquidity in the housing market and improved consumer access to 30-year, fixed-rate mortgages, said David Stevens, chief executive of the Mortgage Bankers Association.

Fannie and Freddie buy mortgages from banks and other lenders, then package them to sell to investors as bonds. The companies insure the bonds to protect investors from facing losses if borrowers default. This helps to ensure that lenders can sell their loans, freeing them up to issue more mortgages.

The loans insured by Fannie Mae are considered safer today than the loans that were common before the financial crisis, Stevens said. Still, the company is likely to face change as the Trump administration and regulators push for ways to change Fannie and Freddie to reduce government ownership.

“These companies fell into conservatorship because they collapsed under the weight of the recession,” Stevens said. “They need to be reformed such that they don’t cost taxpayers a second time.”

Fannie Mae veteran David Benson will become president, giving him control over the day-to-day business operations. Benson has been with Fannie Mae for 16 years, including five years as executive vice president and chief financial officer.

As part of the leadership shake-up, Celeste Brown will replace Benson as executive vice president and chief financial officer. Brown joined Fannie Mae a year ago after 18 years at Morgan Stanley, where she worked as an equity analyst, head of investor relations and global treasurer.

“Tim deserves credit for managing Fannie through a tumultuous time,” Stevens said. “This next appointment is going to be equally important.”