U.S. crude oil futures settled up 26 cents, or 0.76 percent, at $34.66 a barrel. Earlier in the session, WTI briefly rose to $35.17, its highest since Jan. 6. U.S. stocks came off session lows to try for gains.
"I think there's more near-term upside if we hold $34.80. The next level would be $37 - $38," said John Caruso, senior market strategist at RJO Futures. "Stocks, they still look like they want higher. They're really holding on to those gains."
The stability in oil was supported by momentum and hopes of curbing oversupply. The U.S. oil inventory report showed a build in stockpiles but a continued decline in production, down 25,000 to 9.077 million barrels a day, according to StreetAccount.
"If production's coming down it's going to have a positive effect, especially on WTI," said Art Hogan, chief market strategist at Wunderlich Securities.
Reuters also reported in late-morning trade that Venezuela's Oil Minister Eulogio Del Pino said more than 15 countries will attend an upcoming oil meeting to discuss an output freeze plan and possible further actions, state oil company PDVSA said in a statement on Wednesday, according to Reuters.
The news was the latest development in hopes of talks between OPEC and non-OPEC producers to freeze production at January's record-high levels.
Energy and financials were among the top S&P 500 advancers, while materials lagged. IBM contributed the most to gains in the Dow Jones industrial average, while Nike and DuPont weighed.
"Not very exciting considering how volatile things have been," said Randy Warren, chief investment officer at Warren Financial Service. "I think it's best for investors to dollar-cost average into the market."
Earlier, the major averages touched session lows as U.S. crude oil futures briefly fell 2 percent below $34 a barrel after the U.S. Energy Information Administration data showed a build of nearly 10.4 million barrels, more than the 9.9 million barrels the American Petroleum Institute reported late Tuesday.
"The oil inventories were very negative in terms of today's trading overall for oil," said Peter Cardillo, chief market economist at First Standard Financial.
"Considering yesterday's strong close, the markets are lower but not really much lower. It could be much worse. What we're seeing here is a market that is still following oil, but oil is being less of a problem for the market," he said.
U.S. stocks traded little changed to slightly lower for much of the morning session.
"Obviously we had a meltup yesterday, so it's natural we might peel some of that back," said Mark Luschini, chief investment strategist at Janney Montgomery Scott. "Otherwise we're setting up for jobs Friday."
The ADP employment report showed U.S. private employers added a more-than-expected 214,000 jobs in February. Treasury yields edged higher after the report.
"I think it continues to suggest we're in the midst of a very robust labor market," said Ryan Larson, head of equity trading, U.S., RBC Global Asset Management (U.S.).
Treasury yields traded mixed as of 4:03 p.m., with the 2-year yield flat at 0.8491 percent after earlier hitting 0.905 percent, its highest since Jan. 14, while the 10-year yield traded a touch higher near 1.8371 percent after earlier touching its highest since Feb. 5.
The U.S. dollar index traded mildly lower against major currencies, with the euro at $1.0869 and the yen at 113.41 yen against the greenback.
San Francisco Fed President John Williams, a non-voting member, said in a Reuters report that raising rates gradually is the "right strategy." The U.S. economy still needs "some accommodation" over the next few years but it is powering through headwinds from abroad and faces no tangible risk of recession.
"I think one of the things that is important to see come to light after days like yesterday (is) we're not giving back gains in subsequent days," Larson said.
Read More Fading recession fears bring out the bulls
The major averages closed 2 percent higher or more Tuesday for their best first trading day of a month since January 2013. The Nasdaq composite outperformed with gains of 2.89 percent, closing above its 50-day moving average for the first time in 2016. The S&P 500 and Dow also ended above their 50-day moving averages.
"You're hard pressed to find a real answer why the market gapped up the way it did (Tuesday) especially after Monday's lousy performance. ... I think yesterday you had the big heavy buying. Today you have the market pausing," said Adam Sarhan, CEO of Sarhan Capital.
In political news, Donald Trump was the projected winner of seven GOP primaries, NBC News reported. U.S. Secretary of State Hillary Clinton won seven states, although Vermont U.S. Sen. Bernie Sanders had a solid showing by taking four states.