The Dow transports closed up more than half a percent on the day, holding gains of more than 5 percent for the year so far.
"Transports continue to tell a story about the economy that's different from the mainstream," said Art Hogan, chief market strategist at Wunderlich Securities.
U.S. crude oil futures settled up 87 cents, or 1.73 percent, at $51.23 a barrel, its highest settle since July 15.
EIA data showed a draw of 3.2 million barrels in crude and builds in gasoline and distillate inventories. U.S. crude production edged higher, reversing a recent trend of declining output.
Late Tuesday, API reported a larger-than-expected U.S. crude stockpile draw, Reuters said.
"Maybe it's the rise in oil prices," said Peter Boockvar, chief market analyst at The Lindsey Group.
"I don't have any specific rational reason," he said of the gains in stocks, adding that "the underlying story that's being ignored is the continued reduction in growth and the decline in earnings."
The Nasdaq composite closed higher, helped by gains in shares of Alphabet, after earlier dipping into negative territory. Appleand the iShares Nasdaq Biotechnology ETF (IBB) both closed mildly lower.
"I think the market needs to consolidate around these levels. That's bringing in some selling around this time," said Peter Cardillo, chief market economist at First Standard Financial.
In economic news, the Job Openings and Labor Turnover Survey showed there were about 5.8 million job openings at the end of April.
The World Bank downgraded its 2016 global growth forecast to 2.4 percent from the 2.9 percent forecast in January.
"The investors already know global demand is already waning and is not that strong," said Adam Sarhan, CEO of Sarhan Capital, "but they're hoping the Fed and central banks are going to err on the side of easy money and eventually the economy will kick into gear. But that's a big hope."
Treasury yields traded lower, with the 2-year yield last around 0.77 percent and the 10-year yield near 1.70 percent.
The Treasury auctioned $20 billion in 10-year notes at a high yield of 1.702 percent. The bid-to-cover ratio, an indicator of demand, was 2.70, above a 10-auction average of 2.62. The share of indirect bidders was a record high 73.6 percent.
The German 10-year bund yield held off session lows, after earlier hitting a fresh record low of 0.033 percent, according to Reuters Tradeweb data going back to 1992. The European Central Bank began its corporate bond purchase program Wednesday.
"Investors are being forced into risk assets," Sarhan said.
European stocks closed lower, with the German DAX off more than half a percent and the STOXX Europe 600 down nearly half a percent. The STOXX Europe 600 Banks index closed more than 1 percent lower.
Asian stocks closed mixed, with the Nikkei 225 up 0.9 percent and the Shanghai composite off 0.3 percent.
China's May trade data released overnight showed imports fell 0.4 percent, the smallest year-over-year decline since turning negative in November 2014, Reuters said. Exports declined a more-than-expected 4.1 percent.
Crude oil imports jumped the most in over six years, with iron ore imports the highest since December, the news wire said. Copper purchases were up more than 19 percent.
The Dow Jones industrial average closed up 66.77 points, or 0.37 points, at 18,005.05, with UnitedHealth leading advancers and DuPont the greatest laggard.
The S&P 500 closed up 6.99 points, or 0.33 percent, at 2,119.12, with industrials leading eight sectors higher and telecommunications and energy the only decliners.
The Nasdaq composite closed up 12.89 points, or 0.26 percent, at 4,974.64.
The CBOE Volatility Index (VIX), widely considered the best gauge of fear in the market, held steady near 14.
Gold futures for August delivery settled up $15.30 at $1,262.30 an ounce.
—Reuters contributed to this report.
On tap this week:
8:30 a.m. Initial claims
10 a.m. Wholesale trade
1 p.m. $12 billion 30-year bond auction
10 a.m. Consumer sentiment
2 p.m. Federal budget
*Planner subject to change.