Stocks lost ground in the final minutes of trading but still showed resilience after Tuesday's sharp sell-off to end with modest gains, even as oil prices climbed above $100 a barrel.
TheDow Jones Industrial Average rose 8.78 points, or 0.07 percent, to close at 12,066.80, a day after a selloff of more than 1 percentas oil prices soared.
Caterpillar and 3M led gainers on the blue-chip index, while JPMorgan and Boeing fell.
The S&P 500 rose 2.11 points, or 0.16 percent, to close at 1,308.44, while the tech-heavy Nasdaq also gained 10.66 points, or 0.4 percent, to close at 2,748.07. The CBOE Volatility Index, widely considered the best gauge of fear in the market, fell below 21.
Among key S&P 500 sectors, energy, tech and industrials rose, while financials fell.
The Federal Reserve's "beige book" of regional economic activity showed the economy expanded at a modest pace and that manufacturers and retailers have been able to push some price increases through.
The market initially fluctuated after the news before settling higher. Of bigger concern to market participants at the moment are oil prices and the potential for Middle East unrest to spread, particularly to Saudia Arabia. The Saudi market tumbled to a 22-month lowamid calls for nationwide protests later this month.
"If we continue to see that sell off, that tells us what investors on the ground are terrified of," said Quincy Krosby, market strategist at Prudential Financial.
The market also may be effectively treading water on Wednesday as investors await Friday's release of government jobs data, Krosby said.
"This number should highlight the underpinnings we’ve seen in many of the surveys suggesting private sector job creation is gaining momentum," she said.
Earlier, a private industry report from ADP Employer Services and Macroeconomic Advisers showed U.S. private employers added 217,000 jobs in February. Economists expect the Labor Department will report a 185,000 gain in nonfarm payrolls, and a 190,000 gain in private-sector jobs when the data is released Friday, according to Reuters.
Oil markets continued to be rattled by news in the Middle East, as forces loyal to Muammar Gaddafi intensified fighting, and a Libyan warplane reportedly dropped a bomb near an oil exporting terminal. U.S. light sweet crude closed above $102 a barrel, its highest close since Sept. 26, 2008, while London Brentcrude closed above $116.
Gold soared to close at $1437.20 an ounce, hitting a new record. The dollar fell against a basket of currencies, and the euro rose to a four-month high against the U.S. currency.
Semiconductors led the market higher after JPMorgan upgraded the sector to "constructive" from "cautious." The brokerage cited Texas Instruments as its top pick, raising its rating on the stock to "overweight" from "neutral." JPMorgan also raised Xilinx and ON Semiconductor to "overweight" from "neutral."
Also on the tech front, Apple gained after the firm's CEO Steve Jobs took the stage to unveil the second version of the iPad,returning to the spotlight after a brief medical absence.
In the wake of the announcement, Zagg, which makes makes protective covers for devices like the iPad, fell more than 20 percent, since the new iPad includes its own cover. But Silicon Image , which makes digital processing technology compatible with iPad, soared more than 20 percent.
Yahoo gained after news the Internet site is in talks to exit its joint venture in Japan with SoftBank. And Evercore Partners raised its rating on the firm to "overweight" from "equal weight."
Tivo , however, sank a day after reporting a bigger loss than analysts expected, and forecasted slowing sales.
In earnings news, Costco fell despite posting a 16 percent jump in profit, boosted by strong sales during the holiday season, while BJ's Wholesale rose slightly after beating expectations.
Staples slumped after reporting a lower-than-expected profitas inclement weather in many of the officer supply retailer's markets kept shoppers away.
Weatherford shares tumbled after the oilfield services company said it would adjust results for the past four years by $500 million due to a "material weakness" in its tax reporting.
In corporate news, MetLife slipped after AIG said it was accelerating plans to cash out of its stake in the insurer through share sales that could raise more than $9 billion in proceeds, most of which will be used to repay U.S. taxpayers for the AIG bailout ahead of schedule.
New York Times shares gained more than 4 percent despite reporting a continuing drop in print advertising sales.
Volume on the consolidated tape of the New York Stock Exchange was 4.1 billion, while 1 billion shares changed hands on the NYSE floor.
Fed Chairman Ben Bernanke said in a testimony before the House Financial Services Committee that the House GOP spending cuts plan would reduce economic growth by as much as two-tenths of a percentage point and hurt job growth.
"That would translate into a couple hundred thousand jobs," Bernanke said. "It is not trivial."
This comes after Bernanke said ahead of the Senate Banking Committee that gains in oil prices were unlikely to roil the U.S. economy, although if oil prices remain high, that could stall growth and boost inflation. Bernanke said he is no longer concerned deflation will hurt the economy, but that he expects inflation to remain low.
Elsewhere in economic news, applications for home mortgages fell last week as refinancing activity dropped.
Retail sales for Februarywill be reported on Thursday, and were expected to show a gain of about 3.6 percent, according to the Thomson Reuters Same Stores Sales Index.
Shares in Europe fellas the conflict in Libya deepened.
WEDNESDAY: Atlanta Fed President Lockhart speaks.
THURSDAY: Chain store sales, ECB announcement, Monster employment index, jobless claims, productivity and costs, ISM non-manufacturing index, natural gas inventories, money supply; Minneapolis Fed President Kocherlakota speaks, Atlanta Fed President Lockhart speaks; earnings before-the-bell from Heinz, Kroger; earnings-after-the-bell from Novell.
FRIDAY: Non-farm payrolls report, factory orders; Federal Budget Deadline.
More From CNBC.com: