Another rally in crude oil pushed prices to three-week highs and lit a flame under the energy sector, leading to gains in the S&P 500.

The S&P 500 ended Wednesday with slight gains of 0.11%, trailing behind the Nasdaq which rose 0.38% and spent the bulk of the day higher. The Dow Jones Industrial Average was not as fortunate, logging slight losses of 0.20% after a day in the red. The Dow closed with losses for the ninth session of 10. 

Crude oil prices rose on Wednesday after domestic inventories added 900,000 barrels over the past week, according to the Energy Information Administration. Analysts had expected a higher increase after the American Petroleum Institute showed a rise of 1.9 million barrels.

Crude closed at its highest level in a week on Tuesday after production hurdles in Libya eased pressure on high global output. A militia in Libya shut down pipelines on Monday in protest of wages.

West Texas Intermediate crude was up 2.4% to $49.51 a barrel on Wednesday.

The energy sector was the top performer on Wednesday. Chesapeake Energy (CHK) , Whiting Petroleum (WLL) , Petrobras (PBR) , and Hess (HES) were all higher, while the Energy Sector Sector SPDR ETF (XLE) added 1.39%.

Financials stocks were under pressure again on Wednesday, dragging on the Dow, as losses continued after Tuesday brought much-needed relief. Dow components Goldman Sachs (GS) and JPMorgan (JPM) were slightly lower, while lesser-known stocks including Fang Holdings (SFUN) , Mizuho Financial (MFG) and ORIX (IX) declined.

Boston Federal Reserve President Eric Rosengren struck a hawkish tone in comments to the Boston Economic Club on Wednesday. Rosengren said the Fed should hike rates three more times this year and that the central bank should move away from its data dependence to a bias toward tightening its monetary policy.

Chicago Fed President Charles Evans said on Wednesday that he supports one or two more interest rate hikes in 2017, in-line with the central bank's target of two more this year. Evans also said the likelihood of sustainable 3% to 4% GDP for the U.S. economy was low, even as Donald Trump champions that kind of growth.

Amazon (AMZN)  and Alphabet (GOOGL) led the tech sector. Amazon announced late Tuesday that it would add 1,000 full-time jobs when it opens a new fulfillment center in Clear Brook, Va. The e-commerce company already employs 3,500 full-time positions at three sites in the state. Shares rose 2.14% to a record high of $874.32.

Alphabet was initiated with an overweight rating and $1,065 price target at Barclays. The company can generate 20% annual sales and earnings growth for the next few years, Barclays said. The stock rose 1.1%.

Alphabet is a holding in Jim Cramer's Action Alerts PLUS Charitable Trust Portfolio. Want to be alerted before Cramer buys or sells GOOGL? Learn more now.

The United Kingdom took the expected first step to formally remove itself from the European Union, a relationship that has lasted more than four decades. U.K. Prime Minister Theresa May activated Article 50 of the Lisbon Treaty Wednesday morning by notifying European Council President Donald Tusk by way of letter. The notification kicks off two years of negotiating trade, immigration, and other economic deals between the U.K. and the EU.

"We all want to see a Britain that is stronger than it is today," May said in a statement. "We all want a country that is fairer so that everyone has the chance to succeed. We all want a nation that is safe and secure for our children and grandchildren."

The U.K. voted in favor of "Brexit" last summer in a shock win that rocked markets at the time. However, global markets mostly have readjusted to the new reality just as they did following Donald Trump's surprise election win in November. Analysts note that the long lead time heading into Article 50 means that markets have mostly priced in the move by Wednesday. 

"My conversations with EU officials in Brussels last week made clear there is now less appetite in the EU to punish Britain; the continent needs all the friends it can muster, in light of frosty (and, arguably, belligerent) signals from the Trump administration," said Patrick Chovanec, chief strategist at Silvercrest Asset Management and an adjunct professor at Columbia University's School of International and Public Affairs.

The Dow ended an eight-session losing streak on Tuesday with a triple-digit gain, clawing back from some of the heavy losses seen over the past week. The blue-chip index had suffered its longest losing streak since 2011 after closing Monday with its eighth day of losses in a row. The Dow hasn't had nine consecutive losses since the late 1970s. Stocks were under pressure for much of Monday as Wall Street contemplated the way forward for the Trump White House after its defeat on health care reform.

Pending home sales in the U.S. in February rose far faster than analysts anticipated, according to the National Association of Realtors. Sales rose by 5.5%, their highest level in almost a year and the second-best level in more than a decade. Analysts anticipated an increase of 2.4%. Pending home sales measure deals in which an agreement has been made but a contract not yet signed. 

If you liked this article you might like

Amazon Teams With Food Delivery Service to Launch Amazon Restaurants

LA Times Tops 100,000 in Digital Subscriptions

The 10 Craziest Pumpkin Spice Items You Can Buy off Amazon

The 12 Most Ridiculous Kitchen Appliances You Can Buy From Amazon