The Sensex swung in a range of more than 300 points before ending at 18,489, higher by 43 points and the Nifty ended at 5536, up 13 points.
The midcap index ended at 6598, higher by 21 points and smallcap index ended at 8019, up 16 points.
The markets had a gap-down opening as they would have attempted to catch up with their global peers after the holiday on Wednesday.
The US markets had a rough time on Tuesday, although there was a marginal reversal in the previous session, due to the unabated strife in West Asia.
Moreover, oil has been holding firm above the $100 a barrel mark.
There was a bounceback in mid-noon trades, with the benchmark indices hitting their highest levels in nearly two weeks, on easing food inflation and the buzz that the Libyan crisis may be heading towards a settlement, with Gaddafi reportedly agreeing to a peace plan proposed by Venezuelan President Hugo Chavez.
Unconfirmed reports of a firing raid in Libya dragged our indices lower thereafter before yet another bounceback in the last hour of trade led to a respectable closing.
Food inflation declined by more than one percentage point to 10.39% for the week ended February 19, led by a drop in the prices of onions, potatoes and pulses.
Food inflation stood at 11.49% in the previous reporting week and 21.62% in the corresponding period a year ago. According to data released by the government, prices of potatoes declined by 12.66% year-on-year, while pulses fell by 5.02%, onions by 3.64% and wheat by 2.06%.
Across the European continent, the FTSE, DAX and CAC were trading in the positive in the mid-morning
And the Asian markets ended on a firm note, with the Seoul Composite gaining more than 2%, while the Hang Seng and Nikkei adding upto half a percent each.
Reliance Infra weakened by 3.3% at Rs 597 to emerge as the top loser on the BSE. Bharti Airtel shed 2.1% at Rs 330 and Infosys lost 2% at Rs 3025.
The metal sector also took it on the chin on concerns that higher crude oil prices may impact global economic recovery; Tata Steel slid by 1.7% at Rs 623, Sterlite lost 1.7% at Rs 167 and Hindalco lost 1.1% at Rs 210.
The Tata Steel counter seems to have also been affected by reports that the company has increased its stake in Riversdale Mining of Australia by nearly 3% from 24.2% to 27.1%.
On the other hand, autos and select financials continued their post-Budget rally for the third consecutive session. Tata Motors raced ahead by 3.6% at Rs 1182, Maruti Suzuki appreciated by 2.7% at Rs 1328 and M&M added 1.2% at Rs 674. And in the financials space, HDFC strengthened by 3% at Rs 670 and HDFC Bank added 2.9% at Rs 2200.
The market breadth was negative.
Out of 2940 stocks traded on the BSE, there were 1392 advancing stocks as against 1449 declines.