Stocks retreated from session highs, and briefly dipped into the red, on Wednesday after the Federal Reserve held rates steady but left a potential December rate hike in play. 

The S&P 500 was up 0.19%, the Dow Jones Industrial Average added 0.15%, and the Nasdaq gained 0.13%.

"In determining whether it will be appropriate to raise the target range at its next meeting, the Committee will assess progress--both realized and expected--toward its objectives of maximum employment and 2% inflation," the Fed said in a statement. 

Investors had hoped the Fed would provide further clarification on how likely a rate hike this year might be. The Fed left rates unchanged at crises-levels following the conclusion of its two-day meeting. The Fed funds rate is currently zero to 0.25%. The Fed downplayed the global market environment, saying it was monitoring the situation.

"Today's monetary policy statement keeps a potential rate hike on the table. This means that economic data over the next six months will be meticulously dissected through the lens of Fed policy," said Matt Weller, senior market analyst at FOREX.com. "We could see a big move over the low-liquidity holiday period, regardless of what the [Fed] decides."

The energy sector rallied on a better-than-expected read on crude inventories. Crude inventories rose by 3.4 million barrels over the past week, according to the Energy Information Administration, in-line with analysts' expectations. Distillate inventories, which include diesel, fell by 3 million barrels, a faster pace than an expected 1.7 million-barrel decline. West Texas Intermediate crude oil gained 5.8% to $45.71 a barrel.

The energy sector rebounded on the data following two straight days of declines. Among the best performers, Exxon Mobil (XOM) - Get Report , Chevron (CVX) - Get Report , Royal Dutch Shell (RDS.A) , BP (BP) - Get Report and Schlumberger (SLB) - Get Report rose, while the Energy Select Sector SPDR ETF (XLE) - Get Report added 2.1%. 

TheStreet Recommends

AIG (AIG) - Get Report shares climbed 3.9% after activist investor Carl Icahn disclosed a stake in the company and called for a breakup of its assets. In an open letter to CEO Peter Hancock, Icahn said the insurance company was "too big to succeed" and faces increasing regulatory pressure due to its size.

In earnings news, Apple (AAPL) - Get Report climbed 2.5% after iPhone sales in China boosted overall quarterly revenue. The tech giant earned $1.96 a share in its recent quarter, above estimates of $1.88. Revenue jumped 22% to $51.5 billion and beat forecasts. The company sold 48.04 million iPhones during the quarter, only two days of which included sales of the new iPhone 6S and 6S Plus.

Twitter (TWTR) - Get Report slumped 5.4% after releasing a disappointing sales outlook and slowing user growth. The social network expects fourth-quarter revenue in the range of $695 million to $710 million. Analysts had expected an average $741 million. Over the third quarter, the company reported 320 million average monthly active users, up 11% from a year earlier, but 4 million short estimates.

Anthem (ANTM) - Get Report shares were more than 1% lower despite a better-than-expected quarter. The health insurance company earned an adjusted $2.73 a share over its third quarter, 40 cents above estimates. Results were boosted by an increase in medical enrollment, particularly in its commercial and government segments.

Hershey (HSY) - Get Report dropped 4% after a 31% decline in third-quarter earnings. The chocolate company was hit by higher restructuring costs over the quarter as it reduces costs to combat weaker demand and increasing costs for cocoa.

Gilead Sciences (GILD) - Get Report fell 2.6% after quarterly sales of its key hepatitis C treatments came in flat year over year as health insurers opted for less expensive medicine. However, the drugmaker did top revenue and earnings estimates over the quarter.

Walgreens Boots Alliance (WBA) - Get Report moved higher after agreeing to acquire rival Rite Aid (RAD) - Get Report for $9.4 billion, or $9 a share. The all-cash deal combines the second- and third-largest drugstore chains in the U.S.

Separately, Walgreens reported a better-than-expected quarter, boosted by the inclusion of Alliance Boots sales after its acquisition closed. Net income of 88 cents beat estimates by 7 cents, while revenue of $28.52 billion topped forecasts by $70 million.

Starwood Hotels (HOT) spiked 9% on reports Hyatt Hotels (H) - Get Report is in advanced talks to purchase the hotel chain. Sources said an agreement could be reached in as little as a week, according to CNBC. Hyatt shares added 5%.