After a weak start and a subsequent long spell in negative territory, the market moved up in the final hour and ended moderately higher on Tuesday.
Weak Asian markets and profit taking dragged down stock prices early on, but the market found support towards the end of the session.
The Sensex, which declined to 19,632.59 in afternoon trade, ended at 19,746.48 (provisional) with a gain of 55.06 points or 0.28%.
The Nifty closed at 6002.85, up 14.45 points or 0.24%.
Realty stocks rebounded in late afternoon trade and mostly ended higher.
FMCG, healthcare and power stocks too posted notable gains.
Bank, automobile and oil stocks ended on a mixed note.
IT, capital goods, metal and consumer durables stocks were weak.
Midcap and smallcap stocks were mostly subdued.
The market breadth was even.