After a better start, the Sensex fell to the day's low of 19,652.69 before ending with a gain of 30.62 points, or 0.16 per cent, to 19,722.29.
Brokers said the buying activity was mostly confined to banking and healthcare sectors as inflation eased to over three years low.
Softening food prices pulled down inflation to over three year low of 4.89 per cent in April, giving RBI space to further ease interest rates.
The market also improved on speculators covering their pending short positions created in the previous session's steepest fall in one year, traders added.
More From This Section
The MCX-SX flagship index SX40 closed 17.20 points up, or 0.15 per cent, to 11,679.54 points.
Sun Pharma at Rs 963.65 was the biggest gainer by rising 2.03 per cent followed by ONGC by 1.78 per cent at Rs 326.50 and Bharti Airtel by 1.78 per cent at Rs 317.20.
In 30-BSE index components, 15 stocks gained while other 15 closed with losses.
State Bank of India stocks spurted by 0.75 per cent to Rs 2,291.30 and HDFC Ltd by 0.66 per cent to Rs 868.95 on hopes the easing inflation might provide enough room for the Reserve Bank of India to cut interest rate.