U.S. stocks closed higher Tuesday, supported by stabilization in oil prices and high expectations for the first rate hike in nine years.
"It's three things. The backdrop coming into this week is, very oversold. Then it's the ramp up in front of a Fed meeting, which (we've had) historically, and energy stabilizing at the same time is frosting on the cake," said Art Hogan, chief market strategist at Wunderlich Securities.
The major averages ended off session highs, but on track for gains of more than 1 percent for the week, ahead of the Federal Reserve's decision due Wednesday afternoon.
Energy and financials jumped more than 2 percent each to lead all S&P 500 sectors higher.
Goldman Sachs contributed the most to gains in the Dow Jones industrial average, which closed about 150 points higher after earlier gaining more than 250 points.
"I think guys are now at the point they're just trying to get a position ahead of the Fed," said Jeremy Klein, chief market strategist at FBN Securities. He also noted support for stocks from a likely 2015-bottom in crude, and some encouragement from the morning's CPI report.
The Nasdaq composite failed to hold above the psychologically key 5,000 level but still ended higher, shaking off a nearly 1.8-percent decline in Apple, which fell following news its supplier Dialog Semiconductor lowered guidance.
"There's still a little uncertainty. That's why I think you can still slingshot higher (after the Fed decision)," Klein said.
Recently beaten-down areas of the market mostly recovered on Tuesday, helping lift stocks overall.
Oil continued to rebound from near-seven-year-lows hit Monday, with U.S. crude settling higher for the second-straight day, up $1.04, or 2.86 percent, at $37.35 a barrel. From Monday's low to Tuesday's high, WTI rallied nearly 10 percent.
"To some degree markets were oversold and the downdraft we saw in markets in high-yield and in energy prices (was) over-exaggerated," said Jeremy Zirin, head of investment strategy at UBS Wealth Management Americas.
The SPDR Barclays High Yield Bond ETF (JNK) and iShares iBoxx USD High Yield Corporate Bond ETF (HYG) gained about 1.2 and 1.6 percent, respectively. The ETFs declined sharply over the last few days amid news that a roughly $800 million junk bond fund was preventing withdrawals.
"At least for now high-yield is bouncing. That's also lending support," said Peter Boockvar, chief market analyst at The Lindsey Group.
The gained nearly 1 percent with CSX leading advancers. The Dow transports fell sharply in intraday trade Monday to hit a fresh 52-week low.
In economic news, headline November Consumer Price Index (CPI) came in unchanged, while ex-food and energy the figure rose 0.2 percent. In the 12 months through November, the core CPI rose 2.0 percent, which analysts noted matched the Fed's target for the first time since May 2014.
"Core inflation is gradually moving up. The risk of seeing internally generated deflation is very low and this report will only serve to support (the Fed raising rates)," said David Kelly, chief global strategist at J.P. Morgan Funds.
To be sure, the Federal Reserve has said its preferred inflation gauge is the core PCE deflator, the price index of personal consumption expenditures that excludes food and energy. The latest report showed a 1.3 percent year-over-year increase in October.
"Things are slowly moving in the right direction. It's going to take time. … It doesn't have to hit the Fed's target for them to start raising rates," said Ryan Sweet, director of real-time economics at Moody's Analytics. He expects declines in Chinese producer prices and energy prices to weigh on U.S. inflation in the near future.
Performance since the Fed didn't raise rates at its Sept. 16-17 meeting
The Federal Open Market Committee kicked off its two-day meeting Tuesday, and is due to release its post-meeting statement Wednesday at 2 p.m. ET.
The central bank is widely expected to raise the fed funds rate by a quarter point Wednesday, while emphasizing that the pace of tightening will be gradual. A hike would be the first since June 2006.
"On a six-month time horizon I think the start of the normalization process will be viewed as a positive," UBS' Zirin said.
"If the Fed does not move tomorrow, I think the market in the short and immediate term would be negative," he said.
The U.S. dollar index held about 0.6 percent higher against major world currencies, with the euro near $1.092 and the yen at 121.68 yen against the greenback.
Treasury yields rose, with the at 0.97 percent after hitting its highest level in more than a week, and the 10-year yield near 2.27 percent after touching its highest level in a week.
In other U.S. economic news, the Empire Manufacturing index for December showed minus 4.6, compared with November's minus 10.7 print.
The NAHB housing market index missed expectations for a slight gain with a one-point decline to 61.
Foreigners sold long-term U.S. securities in October after buying for eight straight months, data from the U.S. Treasury Department showed on Tuesday.
Trade in U.S. stocks was volatile Monday, with the Dow Jones industrial average adding 100 points as the close approached, after earlier falling more than 100 points.
"Yesterday's strong close in the SPX suggests the pullback is maturing and shows a welcome reaction to short-term oversold conditions," BTIG Chief Technical Strategist Katie Stockton said in a note Tuesday.
"Importantly, short-term oversold conditions are their most widespread since September 29, suggesting the market will have an underlying bid to it as the Fed announces its decision," she said.
Both the Dow and S&P 500 are still negative year-to-date, while the Nasdaq composite is up about 5.5 percent for the year so far.
Baker Hughes closed lower and Halliburton ended off highs after both stocks resumed trading following the announcement the firms extended the deadline for closing the proposed merger.
The closed up 21.47 points, or 1.06 percent, at 2,043.41, with energy leading all 10 sectors higher.
The Nasdaq composite closed up 43.13 points, or 0.87 percent, at 4,995.36.
The CBOE Volatility Index (VIX), widely considered the best gauge of fear in the market, held near 21.
About four stocks advanced for every decliner on the New York Stock Exchange, with an exchange volume of 975 million and a composite volume of about 4.3 billion.
Gold futures for February delivery settled down $1.80 at $1,061.60 an ounce.
—Reuters contributed to this report.
On tap this week:
7 a.m.: Mortgage applications
8:30 a.m.: Housing starts
9:15 a.m.: Industrial production
9:45 a.m.: Manufacturing PMI
10:30 a.m.: EIA oil inventories
2 p.m.: FOMC statement
2:30 p.m.: Fed Chair Janet Yellen press briefing
8:30 a.m.: Initial claims; Current account
8:30 a.m.: Philadelphia Fed survey
10 a.m.: Leading indicators
10:30 a.m.: EIA natural gas inventories
4:30 p.m.: Fed balance sheet/money supply
9:45 a.m.: Services PMI
10 a.m.: Atlanta Fed biz inflation expectations
11 a.m.: Kansas City Fed manufacturing index
1 p.m.: Richmond Fed President Jeffrey Lacker speaks on economy
*Planner subject to change.
More from CNBC.com: