Gains were led by realty, power, oil & gas, consumer durables and capital goods stocks.
A general restraint prevailed in the stock market on Thursday with all eyes on GDP data for the June quarter as the Sensex and the Nifty both closed positive for the second day, aided by supporting overseas trend.
The indices were on their toes ahead of release of the growth numbers slated for post-market hours on Thursday.
Since it was the last day for August derivatives contracts, speculators went about covering their short bets in the last lap, which kept the positivity going.
"Market was range bound while short covering emerged towards the close on account of expiry which took the indices to positive. Investors are a little cautious ahead of Q1 GDP data later today.
On the other hand, ease in geopolitical tensions will give some relief to the market," said Vinod Nair, head of research, Geojit Financial Services.
In spite of a lower opening, the 30-share benchmark settled higher by 84.03 points, that is 0.27 per cent, at 31,730.49. The gauge had rallied 258 points in the previous trading session.
The 50-share NSE Nifty ended at 9,917.90, up 33.50 points -- 0.34 per cent -- after shuttling between 9,925.10 and 9,856.95.
Realty, power, oil and gas stocks took the front row. The BSE realty index advanced the most by 1.11 cent, followed by power, consumer durables and oil and gas.
Healthcare, banking and metal came as speed bumps, ending in the negative.
Wipro got top billing surging 2.54 per cent followed by Bajaj Auto that rose 2.24 per cent. Reliance Industries, Maruti Suzuki, Cipla and Asian Paints registered gains of up to 1.88 per cent.
Defence stocks had a field day after the defence ministry, in a major move, has decided to carry out a series of reform initiatives in the Indian Army.
It rubbed off on defence stocks, including Reliance Defence and Engineering (up 6.86 per cent). Astra Microwave Products, Punj Lloyd, BEML and Taneja Aerospace and Aviation went up.
Participants rolled over their futures and options contracts from August series to September, causing deep swings in the market.
Domestic institutional investors (DIIs) remained steadfast in their backing by lapping up shares worth Rs 15,695.51 crore while foreign portfolio investors sold shares of Rs 16,073.21 crore as on August 30.
DIIs bought shares worth Rs 290.78 crore while FPIs liquidated shares worth Rs 12.46 crore yesterday, as per provisional data.
Broader markets kept getting higher, with BSE small and mid-cap indices turning green.
Photograph: Danish Siddiqui/Reuters