NEW YORK (CNNMoney.com) -- The anxiety over Fannie Mae and Freddie Mac, crucial to a recovery of the battered housing market and the economy as a whole, reached a fever pitch on Friday and took shares of the companies and the broader markets on a wild ride.

The wild day capped a brutal week for the shares of the two companies, as investors fled the two giants on worries they would need a bailout that would wipeout the value of their stock.

An early selloff was fanned by speculation of a looming government bailout. The stocks recovered on assurances by a leading senator that no rescue is needed and a Reuters report that said the Federal Reserve is opening up its discount window to Fannie and Freddie.

But after the market closed, Federal Reserve spokeswoman Michelle Smith told CNN that no discussions with Fannie or Freddie about access to the discount window have taken place.

The discount window is a source of funds that traditionally was only available to commercial banks. But after the Fed engineered the purchase of Wall Street firm Bear Stearns in March, it opened the window to investment banks as well.

Smith added that "the Fed is following the situation with Fannie and Freddie closely" and that she was "not prepared to discuss the range of options and alternatives" available to the Fed regarding Fannie and Freddie.

Immediately after the markets opened Friday, shares of Fannie (FNM, Fortune 500) and Freddie (FRE, Fortune 500) fell more than 47% from their already battered closing price the day before.

But the stocks made up much of their earlier losses. Fannie finished the day down 22% while Freddie's stock closed with a 3% loss.

Friday's selloff left both shares down just over 45% for the week and about 75% for so far this year.

Still, analysts say there is little doubt that the federal government would step in to rescue Fannie and Freddie should rising losses and plunging stock prices leave them without the capital they needed to continue to be the primary source of mortgage funding in the nation.

Fannie and Freddie hold or back $5 trillion between them, or about half the mortgage debt in the country.

They play a central role in the U.S. housing market, providing a crucial source of funding for banks and other home lenders, especially since a credit market crisis last summer left them the only major players in packaging pools of mortgage loans into securities for sale to investors.

If they were unable to do so, it would significantly raise the cost and restrict the availability of mortgage loans, causing significantly more problems for already battered housing prices and sales. That in turn would be another significant problem for the overall U.S. economy, as well as global credit markets.

Trying to restore a sense of calm

The problems for Freddie and Fannie weighed on broader markets, causing a sell-off in U.S. stocks, especially hitting major banks, Wall Street firms and home builders. At one point during the day the Dow fell below the 11,000 mark for the first time in nearly two years.

Fannie and Freddie both said in statements issued late Friday that they have the adequate capital they need to operate and to meet targets required by regulators.

"In fact, we have more core capital, and a higher surplus over our regulatory requirement, than at any time in this company's history," said Fannie's statement.

Freddie's statement said speculation in media reports about a government takeover of the firms through a process known as conservatorship was not accurate.

"Freddie Mac is not on the threshold of conservatorship because we are adequately capitalized," said the statement. "The preliminary indications of our expected financial performance for the second quarter, while reflecting the challenges that face the industry, do not point to an immediate need to raise additional capital."

Others also tried to reassure Wall Street that Fannie and Freddie were not in immediate danger of collapse.

In fact, shares of both companies started their modest rebound shortly after 2 p.m. when Sen. Christopher Dodd, D-Conn., the chairman of the Senate Banking Committee, defended the strength of both firms.

Dodd said his discussions with Federal Reserve Chairman Ben Bernanke, Treasury Secretary Henry Paulson, the regulators who oversee the firms and the two companies' CEOs convinced him they have more than adequate capital and that there was no need to even discuss failure or a bailout.

He also vowed quick passage of a long-debated housing bill to give greater oversight of the two companies. The bill passed the Senate Friday night and is expected to be taken up by the house next week.

"There is a sort of a panic going on," he said. "The facts don't warrant that reaction in my view. Fannie Mae and Freddie Mac were never bottom feeders in the residential mortgage markets. People ought to feel confident about them."

Talk about a bailout

The New York Times reported Friday that senior Bush administration officials are considering a plan to have the government take over one or both of the companies if their problems worsen.

But Paulson said Friday that the government's primary focus is making sure that Fannie and Freddie remain "in their current form." On Saturday, The Wall Street Journal reported that Paulson is adamant that a rescue of either company not benefit shareholders - for fear that a bailout would inure investors to risk.

Even before the latest report on a possible rescue plan, investors fled the two stocks this week due to speculation about their future. The drop in their shares raised questions about how difficult and expensive it will be for them to raise needed capital in the future, which fueled further losses in their stock prices.

"Fannie Mae and Freddie Mac have lost investor confidence evidenced by the rapid brutal sell-off in their stocks, which could dramatically hinder their ability to raise any additional capital going forward," wrote Richard Hofmann of research firm CreditSights in a note Friday.

Hoffmann added that the firms' ability to function normally "remain at the core of government efforts to stabilize the mortgage markets."

A number of scenarios were being discussed by bankers and analysts about what the government may do to deal with the crisis of confidence facing the firms.

Jaret Seiberg, a financial services analyst for the Stanford Group, a Washington research firm, said Thursday that the Federal Reserve could purchase some of Freddie's and Fannie's debt or mortgage-backed securities. He also said the Treasury Department could make billions of dollars in loans to the companies or even buy the firm's stock.

"Government officials are always planning for worst-case scenarios and our note is intended to highlight some options that may be available to policymakers," he wrote. "We suspect hybrid versions of these plans also are possible."

Under current law, the Office of Federal Housing Enterprise Oversight (OFHEO), the regulator of Fannie and Freddie, could take control of the firms if their capital falls too far below required levels. It is unclear how the firms would operate in that situation, known as a conservatorship.

OFHEO Director James Lockhart issued a statement late Thursday saying that his agency was closely monitoring the firms' credit and capital positions. But he pointed out that they had already raised $20 billion in capital and that they adequately capitalized, holding funds well in excess of his agency's requirements.

Investor panic

Still, investors were worried that continued problems in the housing market would cause more than the $12.7 billion losses the two firms have lost between them since last July. The decline in their stock value makes raising additional capital to cover those future losses that much more expensive and difficult.

"Our primary concern about Freddie and Fannie is that credit losses are likely to be worse than the management's current judgment, which will further pressure the capital base, and we remain cautious until we are better able to quantify these risks," wrote UBS analyst Eric Wasserstrom in a note Thursday.

Those concerns prompted him to raise his estimated loss for Freddie and to cut his price target for the stock, although, he retained his neutral rating on both firms, rather than urging clients to sell their holdings.

But the biggest worry Fannie and Freddie shareholders faced Friday was what would happen if the government did have to step into rescue them. Certainly, the big selloff earlier in the day reflected some investors' fears that shares of Fannie and Freddie could become worthless in a bailout scenario.

CNN's Scott Spoerry contributed to this report