Stocks fell sharply Tuesday and oil prices spiked as investors became worried about increasingly violent protests in Libya.

Oil prices rose 6 percent to $95 a barrel after the uprising threatened the country's oil production. Libya is the world's 18th largest oil producer, accounting for 2 percent of global daily output. It also sits atop the largest oil reserves in Africa.

At least 250 people have been killed in Libya so far, according to the U.N. Office of the High Commissioner for Human Rights. Key government officials have resigned and air force pilots have defected following a crackdown on protests in Tripoli, Libya's capital.

Traders are worried that the unrest will spread to other oil-rich countries in the region or lead to higher gas prices for consumers. Governments in Libya's neighbors Tunisia and Egypt have fallen in the past month and protests are continuing in other countries in the region including Yemen and Bahrain.

Alan Gayle, senior investment strategist for RidgeWorth Investments, said the deepening unrest in the Middle East is bringing back concerns that crude oil prices could surge. "This puts a damper on consumer optimism, which is really critical at this stage of the recovery."

More On This...

The Dow Jones industrial average fell 50 points, or 0.4 percent, to 12,341 in morning trading.

The Standard & Poor's 500 index fell 9, or 0.7 percent, to 1,334. The Nasdaq composite index fell 32, or 1.1percent, to 2,802.

Airline stocks fell on concerns that rising oil prices could lead to higher fuel costs. Delta Air Lines Inc., American Airlines parent AMR Corp., United Continental Holdings Inc. and US Airways Group Inc. all fell by 5 percent.

Wal-Mart Stores Inc. fell 3 percent after revenue at stores open at least a year fell for the seventh straight quarter. That raised worries about the company's ability to turn around its U.S. business this year. Wal-Mart fell the most of the 30 companies that make up the Dow average.

Barnes & Noble Inc. fell 9 percent after the bookseller said its net income fell 25 percent. The company also suspended its dividend and said it would not forecast its fourth-quarter or full-year earnings following last week's bankruptcy filing by Borders Group.

Shares of refinery operators Holly Corp. and Frontier Oil Corp. were mixed after they said they would merge in an all-stock deal valued at nearly $3 billion. Holly's stock rose less than 1 percent, while Frontier's fell 2 percent.

Bond prices rose, pushing yields lower. The yield on the 10-year Treasury note fell to 3.55 percent from 3.59 percent late Friday. Markets were closed Monday for the President's Day holiday.

News on the economy was mixed. An index of consumer confidence rose to its highest point in three years, but home prices in a majority of cities tracked by the Standard & Poor's/Case-Shiller index fell to their lowest levels since the housing bubble burst.