The Dow and S&P 500 dipped on Wednesday after concerns about FedEx's warning on higher costs, while optimism stirred by Apple Inc's stronger-than-expected iPhone sales helped the Nasdaq.

Shares of Apple rose 2.2 percent to $265.28, and contributed the most to the Nasdaq's slim gain, after news that sales of its new iPhone 4 surpassed some analysts' expectations.

Stocks started the day solidly lower after FedEx Corp , a bellwether package delivery company, said higher costs would constrain 2011 earnings. Its shares were down 3.3 percent at $80.24, while the stock of its larger rival, United Parcel Service Inc , was up 0.9 percent at $63.21.

It made a pretty interesting run to reverse early weakness, said Stephen Carl, principal and head of U.S. equity trading at The Williams Capital Group LP, in New York. Some of the things leading the charge up were IT, industrials and health care.

Also dampening sentiment, the premium that investors demand to hold 10-year Spanish government bonds rather than euro-zone benchmark German Bunds hit a euro lifetime high, even as the European Union and the International Monetary Fund denied a report they and the U.S. Treasury were preparing a financial safety net for Spain.

The Dow Jones industrial average <.DJI> was down 10.66 points, or 0.10 percent, at 10,394.11. The Standard & Poor's 500 Index <.SPX> was down 0.57 of a point, or 0.05 percent, at 1,114.66. The Nasdaq Composite Index <.IXIC> was up 2.55 points, or 0.11 percent, at 2,308.43.

The S&P 500's ability to stay above its 200-day simple moving average -- just above 1,109 -- will be tested after the benchmark closed above that level for the first time in a month on Tuesday.

The slight pullback in the Dow and S&P follows a sharp rally on Tuesday, when all three U.S. stock major indexes finished the session with gains of more than 2 percent.

Leading the Dow's decline were aerospace and defense shares, with aircraft manufacturer Boeing Co down 0.6 percent at $67.08.

Reflecting the housing sector's struggles, the Morgan Stanley housing index <.HGX> fell 0.9 percent after the U.S. government said housing starts fell more than expected in May, to a five-month low, as a federal homebuyer tax credit expired.

On the closely watched energy front, BP Plc agreed to U.S. President Barack Obama's demand to place about $20 billion in a special fund to pay damage claims from the Gulf of Mexico oil spill.

BP's New York-traded shares were down 0.3 percent at $31.29, while shares of some U.S. drillers and other energy companies edged higher. Shares of Transocean Ltd were up 1.1 percent at $49.03, while shares of Halliburton Co advanced 4.2 percent to $26.54.

(Reporting by Caroline Valetkevitch; Editing by Jan Paschal)