After opening on a weak note, the 30-share BSE Sensex stabilised in afternoon trade and settled with gains of 42.28 points or 0.10 per cent at 40,487.43. The index swung between a high of 40,645.63 and a low of 40,336.56 during the day.
The 50-scrip NSE Nifty closed 16 points or 0.13 per cent higher at 11,937.50.
Among the Sensex stocks, HDFC emerged as the top gainer, rising by 2.06 per cent, followed by Axis Bank, Maruti, Reliance, Power Grid and Tata Steel.
On the other hand, TCS, HCL Tech, L&T, IndusInd Bank, Tech Mahindra, SBI and ITC lost up to 2.93 per cent.
Sectorally, BSE Energy index rose the most by 1.06 per cent, followed by oil & gas and auto.
BSE IT and realty indices led the losers' chart.
Brent futures, the global oil benchmark, fell 0.81 per cent to USD 63.87 per barrel.
Asian stocks were mixed as investors turned more cautious over US-China trade deal uncertainty amid strong US jobs data and weak Chinese exports numbers. BAL ABM ABM