Solid earnings from U.S. companies, including Ford, 3M Co and United Parcel Service lifted stocks on Tuesday, helping the S&P 500 and the Dow industrials set highs for the year.

Both indices were at their highest in nearly three years.

The Dow Jones industrial average <.DJI> rose 81.89 points, or 0.66 percent, at 12,561.77. The Standard & Poor's 500 Index <.SPX> added 10.11 points, or 0.76 percent, at 1,345.36. The Nasdaq Composite Index <.IXIC> climbed 20.26 points, or 0.72 percent, at 2,846.14.

(Editing by Kenneth Barry)