A big increase in manufacturing last month also encouraged investors.
The Dow Jones industrial average rose 62 points, or 0.4 percent, to close at 15,191 Tuesday.
The Standard & Poor's 500 index rose 13 points, or 0.8 percent, to 1,695. The S&P lost ground seven of the previous eight trading days.
The Nasdaq composite rose 46 points, or 1.2 percent, to 3,818.
Merck led the Dow higher after saying it would cut 8,500 jobs and move its headquarters to save costs. The stock rose $1.13, or 2.4 percent, to $48.74.
More than two stocks rose for every one that fell on the New York Stock Exchange. Volume was average at 3.2 billion shares.