The benchmark Sensex closed at 28,208.76 after it bounced back 115.97 points on late buying in some blue chips, led by healthcare, oil and gas, realty and FMCG sector stocks.
The markets recovered from its initial losses of over 317 points tracking weak Asian cues as Greek voters said 'no' to bailout terms as demanded by its creditors.
The Sensex, which had recaptured the 28,000 level, resumed lower at 27,857.20, slipped further to hit the day's low of 27,774.80.
However, it wiped off losses completely on the back of across-the-board buying at the fag end of the session and rebounded to the session's high of 28,235.31 before ending at 28,208.76, a gain of 115.97 points, or 0.41%.
It had gained 146.99 points in the previous session. Similarly, the 50-share Nifty regained the 8,500 mark by rising 37.25 points, or 0.44%, to end the day at 8,522.15 after shuttling between 8,386.15 and 8,533.15.
For both indices, the readings were the highest close in nearly 2-1/2 months.
In the Sensex pack, Dr Reddy's emerged as the major gainer by surging 3.64% at Rs 3,711.75, followed by Cipla (3.35%) at Rs 652.55.
Brokers said sentiment got a big push after Reserve Bank Governor Raghuram Rajan's comments last week that India's exposure to Greece is limited.
Other prominent gainers in the 30-share index included HeromotoCorp, TCS, HDFC Bank, Lupin and Sun Pharma.
The major Sensex losers were Vedanta, Hindalco, NTPC, Tata Steel and Infosys.
Broader markets such as small-cap and mid-cap indices rose 1.09% and 0.85%, respectively.
Foreign portfolio investors (FPIs) net bought shares worth Rs 356.29 crore last Friday, according to provisional data.
Globally, Asian stocks ended lower while European markets were down in early trade as Greek voters' rejection of austerity proposals sent investors to the relative safety of Treasuries.