Federally backed mortgage giants Fannie Mae and Freddie Mac are dropping their pension plan for employees at the end of the year at the urging of their federal oversight agency, according to a memo the companies sent to their staffs Friday morning.

Company officials had frozen pension contributions earlier this year but decided to eliminate the programs altogether. The actions are being taken at the urging of the Federal Housing Finance Agency, which oversees Fannie and Freddie, the memo said.

The companies plan to transition employees into new retirement accounts, such as 401(k)s, by offering a series of payments over the next five years.

“FHFA has directed us to make these changes to manage the cost of the retirement benefits at a more predictable rate and to limit long-term liabilities,” the memo to Freddie Mac staff said. The changes for both companies take effect Dec. 31.

Those enrolled in the pension plan will not lose the benefits they have accrued, and officials said that the transitional plan will “help ease the impact of this change,” according to the memo.

“Payouts to pension plan participants will be made either in the form of a lump sum or an annuity,” said Fannie Mae spokesman Andrew Wilson.

Fannie Mae and Freddie Mac went into federal conservatorship in 2008 under the FHFA after sustaining big losses in the housing market. Those losses resulted in a $188 billion bailout by the Treasury.

The pension decision will affect thousands in the Washington area, home to roughly two-thirds of Fannie Mae’s 7,000-person staff and the vast majority of Freddie Mac’s 5,100 employees, according to company spokesmen.

The FHFA issued a statement on its Web site saying it made the decision to eliminate risk to Fannie and Freddie and to help conserve their assets. A spokesperson declined to comment further.

Fannie and Freddie join a long list of companies seeking to limit the amount of money they have to set aside for future retirees. The Pension Benefit Guaranty Corp., the federal agency that insures private-sector pensions, has said that the number of plans it backs has dropped from 112,208 in 1985 to 25,600 in 2011.

The changes at Fannie and Freddie affect employees hired before Jan. 1, 2012, according to a five-page document addressing who is eligible and how the transition will work at Freddie Mac. Employees who leave the company before the end of the year with less than five years of service will forfeit the benefits they earned under the pension plan.

The document described a “Thrift/401(k) Savings Plan & New Transitional Retirement Savings Plan” for Freddie Mac employees.

Pension plan recipients at Freddie Mac will each year receive a transition contribution, based on age, ranging from 0.5 percent for those younger than 30 to 6.5 percent for those 50 and older, which will be made for up to five years for those who stay with the company. Employees will also receive matching contributions of up to 6 percent of pay.

There also will be a fixed contribution starting in 2014 where Freddie Mac staff will receive an automatic contribution of 2.5 percent of pay each year.

Jordan Marks, executive director of National Public Pension Coalition, said that studies show pensions have yielded higher rates of investment returns than 401(k) savings plans, which require individuals to pay additional fees.

Staff at Freddie Mac received word of the pension elimination Friday morning from Dwight Robinson, the company’s senior vice president of human resources. “Our leadership remains committed to providing competitive retirement benefits for employees,” Robinson said.

Around the same time, Freddie and Fannie filed notice of the changes with the Securities and Exchange Commission.

Fannie Mae has reported a profit in the first quarter of 2012 and has turned a profit every quarter since. The company had been given $116.1 billion as part of the bailout. As of the second quarter of this year, it has paid $105 billion to the Treasury. Freddie Mac has been profitable since the fourth quarter of 2011 and has paid $40.9 billion to the Treasury.