Technology companies led U.S. stocks solidly higher Tuesday, giving the market its second straight gain.
Consumer-services companies, retailers and health care stocks accounted for a big slice of the broad rally. Banks declined, and oil prices recovered from an early slide.
Strong company earnings and outlooks, as well as some encouraging economic data, helped put investors in a buying mood.
"Even though we're early in the earnings season, the fact that we continue to see good earnings and earnings growth come out is really what's driving the market," said Nana Adae, global investment specialist at J.P. Morgan Private Bank. "Earnings growth ties to fundamentals and fundamentals are key."
The S&P 500 index rose 28.55 points, or 1.1 percent, to 2,706.39. The Dow Jones industrial average gained 213.59 points, or 0.9 percent, to 24,786.63. The latest gain nudged the blue chip average into positive territory for the year.
The Nasdaq composite climbed 124.81 points, or 1.7 percent, to 7,281.10. The Russell 2000 index of smaller-company stocks picked up 16.77 points, or 1.1 percent, to 1,579.80.
While the market has been preoccupied lately with concern over geopolitical and trade tensions, Wall Street has something else to focus on over the next few weeks: company earnings.
Financial analysts are forecasting the strongest growth in seven years for S&P 500 companies, partly because of a resurgent global economy, but also because of expectations that last year's corporate tax cut will have on corporate balance sheets.
"There's no doubt that corporate tax reform is a tail wind for earnings, but organic growth is really what is driving a lot of these earnings," Adae said.
Netflix jumped 9.2 percent to $336.06 after the video streaming service said it gained 7.4 million subscribers in the first quarter, more than analysts expected. Other technology companies also posted gains. Microsoft rose 2 percent to $96.07, while Amazon added 4.3 percent to $1,503.83.
UnitedHealth climbed 3.6 percent to $238.55 after it reported a 31 percent jump in first-quarter profit and said it gained Medicare Advantage and Medicaid customers. The nation's largest health insurer also raised its forecast for 2018.
Celanese gained 3.7 percent to $110.38 after the chemical company's latest results beat analysts' estimates. The company also raised its annual forecasts.
Some companies failed to impress traders. Johnson & Johnson fell 0.9 percent to $130.54 after much-higher spending and one-time charges offset a big jump in the company's first-quarter revenue.
Tesla Motors slid 1.2 percent to $287.69 following reports that the car maker shut down production of its Model 3 mass-market electric car again to solve manufacturing bottlenecks.
Southwest Airlines gave up 1.1 percent to $54.27 after one person was killed and others were injured when one of the airline's jets made an emergency landing at Philadelphia's airport Tuesday following an engine failure.
Investors also got some encouraging economic data Tuesday. The International Monetary Fund upgraded its economic outlook for the United States in 2018, forecasting that the U.S. economy will grow 2.9 percent this year, up from the 2.7 percent it had forecast in January and from the 2.3 percent growth the economy achieved last year. And the Federal Reserve said that U.S. factory output rose slightly last month.
Meanwhile, the Commerce Department said that housing starts rose in March to a seasonally adjusted annual rate of 1.32 million. That helped send homebuilder stocks higher. Hovnanian Enterprises led the pack, climbing 4.7 percent to $2.02.
Bond prices rose. The yield on the 10-year Treasury slipped to 2.82 percent from 2.83 percent late Monday. The decline in bond yields, which influence interest rates on mortgages and other loans, weighed on some bank shares. Comerica fell 3.5 percent to $92.74 and SunTrust Banks fell 2.2 percent to $65.95.
The dollar fell to 107.02 yen from 107.10 yen late Monday. The euro fell to $1.2367 from $1.2381.
Gold fell $1.20 to $1,349.50 an ounce. Silver added 11 cents to $16.79 an ounce. Copper slipped 2 cents to $3.08 a pound.
Benchmark U.S. crude rose 30 cents to settle at $66.52 a barrel on the New York Mercantile Exchange. Brent crude, used to price international oils, gained 16 cents to close at $71.58 per barrel.
In other energy futures trading, heating oil dropped 1 cent to $2.06 a gallon. Wholesale gasoline was little changed at $2.04 a gallon. Natural gas fell 1 cent to $2.74 per 1,000 cubic feet.
Major indexes in Europe also rose. Germany's DAX climbed 1.6 percent, while France's CAC 40 rose 0.8 percent. Britain's FTSE 100 added 0.4 percent.
In Asia, Japan's benchmark Nikkei 225 edged 0.1 percent higher, while Australia's S&P/ASX 200 was unchanged. South Korea's Kospi lost 0.2 percent. Hong Kong's Hang Seng shed 0.9 percent after new data showed China's economic growth held steady in the first quarter.