A bruising legal fight pitting the country’s most powerful banks against the full force of the United States government began Friday, as federal regulators filed suits against 17 financial institutions that sold the mortgage giants Fannie Mae and Freddie Mac nearly $200 billion in mortgage-backed securities that later soured.

The suits are the latest legal salvo fired at the banks accusing them of misdeeds during the housing boom. Investors fled financial shares Friday amid growing concern that the litigation could last for years and undermine earnings and balance sheets in the process.

The complaints were filed just as the stock market closed Friday afternoon, but with word leaking out of the impending legal action during the trading session, shares of Bank of America fell more than 8.3 percent, while JPMorgan Chase dropped 4.6 percent and Goldman fell 4.5 percent.

“The suits only add to the uncertainty that dogs the industry,” said Mike Mayo, an analyst with Crédit Agricole. “Banks should pay for what they did wrong, but at the same time they shouldn’t be treated as a big piñata that has the effect of delaying the housing recovery. If banks have to pay for loans they made five years ago, are they going to make new ones?”