An automated stock trading program suddenly flooded the market with millions of trades Wednesday morning, spreading turmoil across Wall Street and drawing renewed attention to the fragility and instability of the nation’s stock markets.

While the broad stock indexes quickly recovered and ended the day slightly down, it was the latest black eye for the financial markets. The runaway trading suggests that regulators have not been able to keep up with electronic programs that increasingly dominate the supercharged market and have helped undermine investor confidence in stocks.

Traders on Wednesday said that a rogue algorithm repeatedly bought and sold millions of shares of companies like RadioShack, Best Buy, Bank of America and American Airlines, sending trading volume surging. While the trading firm involved blamed a “technology issue,” the company and regulators were still trying to understand what went wrong.

The debacle comes after the botched Facebook initial public offering on the Nasdaq exchange in May and the aborted effort in March by another exchange, BATS Global Markets, to bring its own stock public. The episodes, along with the flash crash of 2010 when the market lost trillions of dollars of value in minutes, have stoked suspicions that stocks are safe only for specialists, and sometimes not even for them.