Earlier in the day, Sensex and Nifty flip-flopped between in negative and positive territories.

The S&P BSE Sensex and NSE Nifty 50 Indexes rose for third day in a row to close at record highs led by gains in Reliance Industries, Infosys, Tata Consultancy Services, HDFC Bank and Yes Bank. Earlier in the day, Sensex and Nifty flip-flopped between in negative and positive territories and the benchmarks swung at least 15 times between gains and losses till 12 noon. In the afternoon trades, benchmarks gave up gains owing to weakness in banking shares. However, the late recovery in the Nifty Bank Index helped Sensex and Nifty settle at all-time closing highs.

The Sensex rose 66 points or 0.17 per cent to close at 39,750 and the NSE Nifty 50 Index climbed 4 points or 0.03 per cent to end at 11,929.

Ten of 19 sector gauges compiled by BSE ended higher led by the S&P BSE Information Technology Index's 1.6 per cent gain.

Energy, metal, oil & gas, power and teck Indexes on BSE also rose between 0.5 and 1 per cent.

On the flipside, S&P BSE Telecom Index was top loser, down 1.2 per cent.

Mid- and small-cap shares ended on a mixed note as the S&P BSE MidCap Index rose 0.1 per cent and the S&P BSE SmallCap Index advanced 0.41 per cent.

Zee Entertainment was top gainer in the Nifty 50 basket of shares, the stock rose 5.26 per cent to settle at Rs 380 after its consolidated net profit 27 per cent to Rs 292.53 crore from Rs 230.64 crore in the same quarter last year.

Yes Bank, Infosys, Coal India, Power Grid, JSWT Steel, Tech Mahindra, Reliance Industries and Wipro were also among the gainers.

On the flipside, Bharti Infratel, Bajaj Auto, Hero MotoCorp, Grasim Industries, UltraTech Cement, Mahindra & Mahindra and Bajaj Finance were among the losers.

The overall market breadth was positive as 1,438 shares closed higher while 1,169 closed lower on the BSE.