The benchmark index was lower for most of the day, then turned higher in the last 10 minutes of trading, ending up 0.2%.
Trading has been choppy as investors gauge the strength of the economic recovery and whether emerging signs of inflation will be transitory, as the Federal Reserve believes. The Fed holds its latest meeting on interest rate policy this week.
The S&P 500 rose 7.71 points, or 0.2%, to 4,255.15.
The Dow Jones Industrial Average fell 85.85 points, or 0.2%, to 34,393.75.
The Nasdaq rose 104.72 points, or 0.7%, to 14,174.14.
The Russell 2000 index of smaller companies fell 9.66 points, or 0.4%, to 2,326.15.
For the year:
The S&P 500 is up 499.08 points, or 13.3%.
The Dow is up 3,787.27 points, or 12.4%.
The Nasdaq is up 1,285.86 points, or 10%.
The Russell 2000 is up 351.29 points, or 17.8%.