WASHINGTON  Senior officials from the Bush administration and the Federal Reserve on Friday called in top executives of Fannie Mae and Freddie Mac, the mortgage finance giants, and told them that the government was preparing to place the two companies under federal control, officials and company executives briefed on the discussions said.

The plan, which would place the companies into a conservatorship, was outlined in separate meetings with the chief executives at the office of the companies’ new regulator. The executives were told that, under the plan, they and their boards would be replaced and shareholders would be virtually wiped out, but that the companies would be able to continue functioning with the government generally standing behind their debt, people briefed on the discussions said.

It is not possible to calculate the cost of any government bailout, but the huge potential liabilities of the companies could cost taxpayers tens of billions of dollars and make any rescue among the largest in the nation’s history.

The drastic effort follows the bailout this year of Bear Stearns, the investment bank, as government officials continue to grapple with how to stem the credit crisis and housing crisis that have hobbled the economy. With Bear Stearns, the government provided guarantees, and the bulk of its assets were transferred to JPMorgan Chase, leaving shareholders with a nominal amount.