Securing the top job at Fannie Mae, which last month posted its first profitable quarter without government support since 2008, represents a vindication for Mr. Mayopoulos, a highly regarded lawyer who joined Fannie Mae as its general counsel in the spring of 2009.

Mr. Mayopoulos was forced out as general counsel at Bank of America as executives were at odds over mounting losses linked to its purchase of Merrill Lynch in December 2008. Mr. Mayopoulos was replaced by Brian T. Moynihan, who went on to become chief executive of Bank of America a year later.

Mr. Mayopoulos takes over for Michael Williams, who in January announced he would step down as chief executive after 21 years at Fannie Mae. Mr. Williams had been in the top post since 2009.

Fannie Mae is at the center of the broader argument over how to fix the housing finance system in the wake of the subprime collapse and the broader financial crisis. Turning Fannie Mae around amid attacks from the left and right has been one of Washington’s most thankless tasks.

“I am excited, but I’m not naïve,” Mr. Mayopoulos said Tuesday in an interview. “I know this is a very difficult and challenging job.”

As chief executive of Fannie Mae, Mr. Mayopoulos will have to weigh in on one of the most contentious issues facing Fannie Mae, and Freddie Mac, the other huge government-sponsored mortgage entity: whether to take principal losses on mortgages it owns to help beleaguered homeowners and aid the battered housing market.

Edward J. DeMarco, the acting director of the Federal Housing Finance Agency, which oversees Fannie Mae and Freddie Mac, has steadfastly opposed principal reduction, despite calls from housing advocates, the White House and some members of Congress to consider it. Fannie and Freddie together own or back more than half of the country’s $12 trillion in mortgages, and each month the two companies guarantee $100 billion worth of new mortgages, equal to three out of every four mortgages originated.

About 10.7 million mortgage holders are underwater. Collectively, their negative equity is almost $700 billion. On average, these homeowners, equal to one in five Americans with mortgages, are underwater by $50,000 each.

At issue now is whether the government will push for some form of principal reduction for mortgage holders who owe more than their homes are worth or whether it will stick to mainly modifying loans by lowering interest rates.

In the interview Tuesday, Mr. Mayopoulos said broad reductions in principal, which would cause billions in additional losses for Fannie Mae, were not necessary.

“I’ve been involved in examining that issue,” he said. “We have the tools we need to assist homeowners with troubled mortgages. I don’t believe we need principal forgiveness as a tool. We are already effective with the tools we have.”

Despite the promotion, Mr. Mayopoulos’s total compensation will actually shrink as a result of the move up, as Fannie Mae hews to promises it made to reduce executive pay after the big taxpayer bailouts of Fannie and Freddie. His pay will fall from $2.6 million in 2012 to $600,000 next year. Mr. Williams earned $5.3 million in 2011.

“I was asked whether I’d be willing to take the lower pay,” he said. “This is a very difficult job and a challenging job, but I’m excited about the prospects of this organization, considering all the good it does.”

Fannie Mae is embroiled with his former employer in an increasingly bitter fight over repurchases of mortgages that the bank originated.

Fannie argues that the mortgages it bought from Bank of America soured because they were underwritten improperly, with little regard for key information like borrower income or assets. Bank of America contends the mortgages, some of which went bad years after they were first made, went into default because of problems in the broader economy, not underwriting procedures.

In February, Bank of America said it would no longer sell mortgages to Fannie Mae.

While Mr. Mayopoulos has recused himself from direct involvement with the repurchase dispute, he said, “I need to be aware, and I will have the appropriate people working on them. I’d want to make sure they are addressed, but I will not be a decision maker on them.”

Fannie Mae is considerably larger than Freddie Mac, but both companies capsized in 2008, amid huge losses caused by the bursting of the housing bubble. The two companies were taken into conservatorship, akin to bankruptcy, in the summer of 2008, just weeks before the collapse of Lehman Brothers.

Unlike the bailouts for some of the nation’s largest banks during the financial crisis — including Bank of America and Citigroup — the rescue of Fannie and Freddie has not yielded a profit for taxpayers. The Treasury has poured $116 billion into Fannie since 2008, of which $23 billion has been paid back in the form of dividends. Freddie Mac has received about $72 billion, of which $18 billion has been returned.

A slowdown in the decline of home prices, along with hints of improvement in some areas, helped Fannie Mae earn a profit and cover its $2.8 billion dividend to the Treasury in the first quarter. But expectations for the economy have dimmed more recently, and the grim unemployment numbers released last Friday do not bode well for the broader housing market, making renewed government assistance a possibility in the future.

“Clearly, we’ve made substantial progress over the last three and a half years,” Mr. Mayopoulos said, noting the most recent quarterly numbers were the healthiest in years. But continued recovery, he said, “is a function of a lot of factors, many of which are beyond our control.”

A version of this article appears in print on June 6, 2012, on page B4 of the New York edition with the headline: Fannie Mae Names Its Top Lawyer as Chief. Order Reprints|Today's Paper|Subscribe