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. With the general firming trend, the broad-based National Stock Exchange index Nifty rose by 14.95 points, or 0.25 per cent, to 5,995.40.
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.
The healthcare sector index gained the most by 0.67 per cent to 8,880.47 followed by teck index by 0.64 per cent to 3,604.51. Power index rose by 0.40 per cent to 1,754.88 and oil and gas index by 0.33 per cent to 8,716.85.