(Reuters) - Shares of government-controlled Fannie Mae (>> Federal National Mortgage Assctn Fnni Me) and Freddie Mac (>> Federal Home Loan Mortgage Corp) plummeted on Wednesday, the day after a judge upheld the U.S. Treasury's right to seize the mortgage finance companies' profits.

Judge Royce Lamberth of the U.S. District Court for the District of Columbia threw out lawsuits brought by investors challenging the government's decision to force the companies to sweep their profits into the Treasury.

The investors, including Perry Capital LLC and Fairholme Funds Inc, had argued the profits sweep marked a breach of contract and an unconstitutional property seizure.

In his decision, Lamberth said the "unambiguous" language of the law that paved the way for the government's bailout of the two firms in 2008 gave the companies' regulator and the Treasury the power to confiscate their profits.

The dismissal of the lawsuit dealt a blow to investors hoping to benefit now that Fannie Mae and Freddie Mac, the two largest sources of U.S. housing finance, are profitable. However, other lawsuits challenging the bailout terms are still pending.

In heavy trading, the over-the-counter common shares of both companies lost more than a third of their value, with Fannie Mae sliding to $1.70 and Freddie Mac dropping to $1.65, on volume of 142 million and 79 million shares, respectively.

The company's preferred shares also dropped sharply, with each down more than 50 percent. Freddie Mac's preferred "Z" shares slid to $4.34 on volume of 33 million. Fannie Mae's preferred "S" shares slumped to $4.15, with about 43.6 million traded.

In a statement, Fairholme signaled it was not ready to let the matter drop. "We will vigorously pursue the enforcement of existing contractual claims and our inalienable rights of property ownership as guaranteed by the United States Constitution," it said.

Perry Capital did not immediately respond to a request for comment.

The government seized Fannie Mae and Freddie Mac at the height of the financial crisis as they teetered on the brink of insolvency.

Initially, they were required to pay a 10 percent dividend on the senior preferred shares the government received. However, the Treasury and their regulator later altered the terms to force them to hand over nearly all their profits.

The Treasury ended up pumping $187.5 billion into the companies, but they have now returned $218.7 billion to taxpayers in the form of dividends for the government's majority stake.

(Reporting by David Gaffen, Tim Ahmann and Svea Herbst-Bayliss; Editing by Bernadette Baum, Lisa Von Ahn, Cynthia Osterman and Richard Chang)