Freddie Mac, the mortgage-funding company operating as a ward of the government, is getting its fourth leader since it was placed under federal conservatorship during the financial meltdown of 2008.

Donald H. Layton, 62, who spent almost 30 years at JPMorgan Chase and its predecessor firms and rose to vice chairman, will become Freddie Mac’s chief executive later this month, the company said Thursday.

Layton was chief executive of E-Trade Financial, an online brokerage, in 2008 and 2009. Since 2010, he has been on the board of American International Group, the big insurance company that received a federal bailout in 2008. He gave up that seat to join Freddie Mac.

Layton is stepping into a role that other executives might see reason to avoid. Because the company is essentially an extension of the government and has received a massive infusion of taxpayer funds, the government has curbed executive compensation there.

“It’s a hard job to fill because of the congressional pay limits,” said Karen Shaw Petrou, managing partner of Federal Financial Analytics and a longtime observer of the business. “You have to be really public-spirited to do it,” she said.

The challenge includes “crafting a future for a company that owes the government more than it could ever hope to repay,” she said.

Layton is replacing Charles E. “Ed” Haldeman Jr., a veteran of the investment industry who announced in October that he would be leaving. The company’s regulator, the Federal Housing Finance Agency, reported in March that it had approved compensation of $3.8 million for Haldeman for 2011 and that he stood to receive as much as $5.4 million for 2012.

At the time, the agency said it was eliminating bonuses for top executives and setting a target of $500,000 for chief executive pay.

Layton is getting more than that — $600,000, Freddie Mac said.

FHFA spokeswoman Stefanie Johnson said by e-mail that his pay was “true to the pledge to substantially reduce CEO compensation.”

It’s a long way from the compensation of Richard F. Syron, who was chief executive when the government placed the company under conservatorship. In an earlier regulatory filing, Freddie Mac valued his 2007 compensation at $18.3 million, including a salary of $1.2 million, a bonus of $3.5 million and $117,731 of perquisites, such as a car and driver.

Layton still has financial ties to JPMorgan, such as stock options and deferred compensation, and Freddie Mac does extensive business with JPMorgan, the company said in a regulatory filing Thursday. To avoid potential conflicts of interest, the company said, Layton has agreed to recuse himself from matters related to JPMorgan “in specified circumstances.”