Stocks were on track to snap a five-day losing streak thanks to a last-minute comeback on markets.

A multitude of worries kept markets under pressure, though: Crude prices tumbled, fears over a "Brexit" lingered and a less-hawkish Federal Reserve raised worries over the health of the U.S. economy.

The S&P 500 was up 0.15%, the Dow Jones Industrial Average added 0.4%, and the Nasdaq was flat. Stocks have fallen for the past five sessions.

Crude oil continued its losing streak, extending losses into a sixth straight session. Oil slid during the previous session after a decline in U.S. inventories over the past week was narrower than analysts had expected. Investors have been pinning their hopes on slower U.S. production to counter record-high output elsewhere on global markets.

West Texas Intermediate crude oil fell 3.8% to $46.21 a barrel on Thursday, settling at a five-week low.

"Crude is on track for a six-day losing streak as easing supply disruptions globally counter a decline in U.S. stockpiles and production," said Joseph George, commodity analyst at Schneider Electric. Energy Information Administration "data on Wednesday showed a fourth straight drop in crude inventories... Nevertheless, prospects of increased supply globally continue to outweigh near-term moves in US supply."

Fears over a possible British exit from the European Union also persisted. U.K. citizens will vote in the "Brexit" referendum on June 23, the results of which could have significant consequences for the economic and political stability of the region. The Fed mentioned a possible "Brexit" as a reason for maintaining rates as is after their June meeting.

The Federal Reserve left rates unchanged at its June meeting just as Wall Street had pegged. What was a surprise, though, was the shedding of hawkish rhetoric that characterized Fed chatter in recent months. The number of Fed officials who expect to see just one rate hike this year rose to six members, up from just one official at the central bank's meeting in April.

"The Fed's communication was more dovish than expected, despite virtually no change in the economic forecasts, implicitly acknowledging increased downside risks (despite no explicit statement on that balance)," said BNP Paribas analysts.

Market reaction to the Fed's expected slower pace highlights an interesting paradox: Investors want lower rates for longer but not at the expense of a weaker U.S. economy.

Fed Chair Janet Yellen did reiterate her confidence in the strength of the U.S. economy, however, but cautioned that investors not overreact to one piece of data, such as the weak May jobs report. Weakness in the first quarter appears to be temporary, Yellen noted at a press conference following the meeting's conclusion.

Homebuilder sentiment in the U.S. improved in May, another sign of a robust housing sector. The National Association of Home Builders' index moved to a reading of 60 after four months remaining unchanged. Homebuilders were most optimistic about the six-month outlook.

Core consumer prices in May rose at a better-than-expected pace, according to the Bureau of Labor Statistics. Excluding energy and food, core prices rose 0.2%, above expectations for a 0.2% decline. The headline number also advanced 0.2%, a touch below an expected 0.3% increase.

"Inflation continues to edge higher, albeit at a very gradual pace," RBS analysts wrote in a note. "The question is whether the Fed believes this trend will be sustained, particularly in the face of low inflation expectations (which are, by some measures, moving even lower)."

The number of new applications for unemployment benefits broke a four-week contraction, climbing by 13,000 to 277,000 in the past week. The measure remains around multi-year lows.

Business conditions in the Philadelphia region improved at a faster-than-expected pace in June. The Philly Fed Business Outlook improved to a reading of positive 4.7 compared to a negative reading a month earlier. Analysts had expected a reading of positive 1.1.

Advanced Micro Devices (AMD)  rose 5% after Canaccord Genuity upgraded the stock to buy from hold. The firm hiked its price target to $6 from $3.25, noting it is impressed with the new management team. Analysts expect modest market share recovery in core markets. 

Yahoo! (YHOO) was upgraded to buy from neutral at Citigroup. The firm said the move was a valuation call based on a $43 price target. The stock was trading down 1%.

Jabil Circuit (JBL) , an Apple supplier, fell after issuing weak guidance for its fiscal fourth quarter and full year. The chipmaker expects earnings no higher than 35 cents a share in its fourth quarter, a far cry from market expectations of 53 cents. The weaker forecasts raised concerns over demand for Apple's products, including its iPhone which recently saw its first quarterly sales decline.

Rite Aid (RAD) dropped after missing first-quarter estimates on its top- and bottom-lines. The pharmacy chain earned an adjusted per-share profit of 1 cent, down from earnings of 2 cents a year earlier. Analysts had expected earnings of 5 cents a share. Revenue rose 23% to $8.18 billion, though missed consensus of $8.24 billion. Same-store sales increased 0.4%, driven by front-end sales which grew 1.2%.

Envision Healthcare (EVHC) tumbled after agreeing to merge with AmSurg (AMSG) , creating a physician services behemoth with an enterprise value of about $15 billion. Shareholders of Envision and Amsurg will own about 53% and 47%, respectively, of the combined company. The new company will encompass a wide array of outsourced physician services in the emergency, hospitalist, anesthesia, radiology and children's services areas.

Chipmaker Cavium (CAVM) slid after agreeing to buy network equipment maker QLogic (QLGC) for $1.36 billion in an effort to diversify earnings away from the highly competitive semiconductor market. Cavium will pay $15.50 a share for QLogic, composed of $11 in cash and 0.098 of a Cavium share. The deal values QLogic at roughly $1 billion.

More from Markets

Stocks Tumble, Dow Futures Plunge as Growth Risks Catch Up to Global Markets

Stocks Tumble, Dow Futures Plunge as Growth Risks Catch Up to Global Markets

Stocks Sink, Caterpillar, McDonald's, Arconic and Bayer - 5 Things You Must Know

Stocks Sink, Caterpillar, McDonald's, Arconic and Bayer - 5 Things You Must Know

Verizon Beats Q3 Earnings Estimate, Postpaid Phone Additions Top Forecasts

Verizon Beats Q3 Earnings Estimate, Postpaid Phone Additions Top Forecasts

Job No. 1 Is to Protect Capital During a Correction, Not Guess Its Length

Job No. 1 Is to Protect Capital During a Correction, Not Guess Its Length

Harley-Davidson Tops Q3 Earnings, Confirms Full-Year Shipment Forecasts

Harley-Davidson Tops Q3 Earnings, Confirms Full-Year Shipment Forecasts