The S&P 500 recovered after falling earlier to within 0.26 percent of lows it touched in August, when fears of a slowdown in China shocked global markets.

"I would never have expected that we would take out that low and we haven’t yet, but we sure are close. A retest is a good thing but it needs to hold," said Randy Frederick, managing director of trading and derivatives for Charles Schwab in Austin.

Seven of the 10 S&P sectors rose, with the healthcare index <.SPXHC> up 0.9 percent, ending a seven-day losing streak, thanks in part to gains in Johnson & Johnson (>> Johnson & Johnson) and Gilead Sciences (>> Gilead Sciences, Inc.).

Pharmaceutical and biotech stocks had faced pressure after Democratic presidential candidate Hillary Clinton criticized drug pricing last week.

The Nasdaq Composite ended lower and the S&P technology index <.SPLRCT> dipped 0.55 percent. Apple fell 3.01 percent a day after reporting record first-weekend sales of its newest iPhones.

Although the market's recent rout has forced many strategists to slash their year-end expectations, a new Reuters poll shows the S&P 500 ending 2015 roughly 11 percent above current levels.

"We're taking a breather after the carnage we saw yesterday and in the last few days," said Robert Francello, head of equity trading for Apex Capital in San Francisco. "I wouldn't be surprised if we go a little lower before we stabilize."

The Dow Jones industrial average <.DJI> rose 0.3 percent to end with 16,049.13 points and the S&P 500 <.SPX> gained 0.12 percent to 1,884.09. The Nasdaq Composite <.IXIC> dropped 0.59 percent to 4,517.32.

Investors are awaiting data scheduled to be released this week, culminating in nonfarm payrolls numbers on Friday.

A report on Tuesday showed the consumer confidence index rose to 103.0 in September, topping economists' expectation of 96.1.

With third-quarter earnings season looming, Goldman Sachs said it expects sales growth for S&P 500 companies to shrink this year for the first time in five years.

After the bell, Diamond Foods (>> Diamond Foods, Inc.) posted fiscal fourth-quarter sales that missed Wall Street's expectations and its stock lost 4 percent.

During the regular session, Yahoo (>> Yahoo! Inc.) shares rose 2.39 percent, a day after the Internet company's board decided to proceed with spinning off Alibaba (>> Alibaba Group Holding Ltd) stake.

Nexstar (>> Nexstar Broadcasting Group, Inc.) rose 8.00 percent after activist investor Starboard Value LP urged regional TV company Media General (>> Media General Inc) to sell itself to Nexstar. [ID: nL3N11Z4EU]

Republic Airways (>> Republic Airways Holdings Inc.) surged 12.85 percent after Deutsche Bank raised the stock to "buy" and the airline reached agreement on new contract with its pilots.

Declining issues outnumbered advancing ones on the NYSE by 1,732 to 1,353. On the Nasdaq, 1,759 issues fell and 1,053 advanced.

The S&P 500 index showed one new 52-week high and 70 lows, while the Nasdaq recorded 15 new highs and 323 lows.

About 7.9 billion shares changed hands on U.S. exchanges, above the 7.3 billion daily average for the past 20 trading days, according to Thomson Reuters data.

(Additional reporting by Charles Mikolajczak in New York, Abhiram Nandakumar and Sweta Singh in Bengaluru; Editing by Saumyadeb Chakrabarty and Nick Zieminski)

By Noel Randewich