The Dow and S&P fell on Wednesday after Morgan Stanley revived concerns about the banking sector and the wider economy after it posted its second straight quarterly loss and slashed its dividend.

The Nasdaq, however, eked out a gain after AT&T reported a profit that fell less than expected, and an analyst said its iPhone partnership with Apple Inc is starting to help rather than hurt profits, lifting tech shares.

The market, which had been up much of the day as investors initially seized on company comments suggesting that corporate profits were stabilizing, has been sensitive to the outlook for banks ahead of the government's stress test results expected in the days ahead.

Morgan Stanley slid 9 percent to $22.44 after it posted its third loss in six quarters on real estate losses and a charge wiped out fees and trading profits. The KBW Bank Index <.BKX> fell 4.9 percent.

Banks have been a key component in leading the six-week rally that drove the broad S&P 500 up nearly 25 percent from March's bear market lows.

The financial sector is still heavily influencing the tone and direction of this market, said Keith Wirtz, president and chief investment officer of Fifth Third Asset Management in Cincinnati.

Equities are just captive to anything that is coming out of financials and today, it was about Morgan Stanley.

The Dow Jones industrial average <.DJI> dropped 82.99 points, or 1.04 percent, to 7,886.57. The Standard & Poor's 500 Index <.SPX> slid 6.53 points, or 0.77 percent, to 843.55. The Nasdaq Composite Index <.IXIC> gained 2.27 points, or 0.14 percent, to 1,646.12.

Before the sell-off in the last hour, the stock indexes had been driven higher by brighter outlooks from companies reporting quarterly results.

JPMorgan recommended that Caterpillar should make up a larger part of investors' portfolios, and Caterpillar's stock rose 3.4 percent to $32.45, making it the Dow's biggest advancer.

AT&T was up 1.8 percent at $25.74 after profit fell less than expected, and an analyst said its iPhone partnership with Apple Inc is starting to help rather than hurt profits.

APPLE AND eBAY CLIMB AFTER THE BELL

After the closing bell, iPhone and iPod maker Apple posted stronger-than-expected quarterly results and gave a typically conservative outlook for the current quarter, sending shares up 2.4 percent to $124.40.

Shares of EBay Inc rose 6.2 percent to $15.70 in extended trade after the online auctioneer reported lower quarterly net profit, sales and profit margins, but results beat Wall Street expectations.

Wireless chip maker Qualcomm said that it was rescheduling its quarterly results due to advanced settlement discussions with Broadcom over legal disputes, but it also said second-quarter revenue and operating income met or exceeded prior guidance.

Qualcomm's stock rose 7.4 percent to $24.28 in extended-hours trading.

FOR NASDAQ, IT'S THE BALM OF GILEAD

During the regular session, Gilead Sciences Inc jumped 5.7 percent to $46.22 and contributed the most to the Nasdaq's gain after its quarterly profit beat estimates on increased sales of its drugs to treat the virus that causes

AIDS.

Semiconductor stocks were a bright spot following strong quarterly results from SanDisk Corp . The PHLX Semiconductor index <.SOXX> advanced 4.3 percent.

Boeing Co rose 1.8 percent to $37.30 after the big U.S. aircraft maker and defense contractor lowered its full-year outlook, but the range was still above Wall Street's expectations, according to Reuters Estimates.

Trading was active on the New York Stock Exchange, with about 1.77 billion shares changing hands, above last year's estimated daily average of 1.49 billion, while on Nasdaq, about 2.69 billion shares traded, above last year's daily average of 2.28 billion.

Advancing stocks outnumbered declining ones on the NYSE by a ratio of about 8 to 7, while on the Nasdaq, 14 stocks rose for every 13 that fell.

(Additional reporting by Jennifer Ablan; Editing by Jan Paschal)