For the week, the Sensex soared 723.03 points, or 3.14 per cent, and Nifty 229.80 points, or 3.29 per cent.
Europe was on mend, which gave investors some confidence.
The start of the 30-share Sensex was shaky, mainly because of renewed worries of oversupply in crude oil.
But higher buying activity and covering-up of short positions ensured no further damage is done as the Sensex closed at 23,709.15, up 59.93 points, or 0.25 per cent.
Also Read
"Markets closed on a strong note extending yesterday's gain on the back of firm global peers. Renewed buying interest by foreign portfolio investors after a long time and recovery in global commodity prices boosted sentiment," said Gaurav Jain, Director, Hem Securities.
Investors were seen building their positions in anticipation of reforms announcement in the upcoming Budget, which will be presented on February 29.
However, higher levels could not be maintained as participants locked in gains. The Sensex had gained 457.25 points in the previous two sessions.
The largest state-owned lender, SBI, advanced 3.20 per cent to Rs 164.65 after the bank raised Rs 3,000 crore from bonds to fund business growth.
Other big gainers included Hero MotoCorp, Asian Paints, Bajaj Auto, NTPC, Bharti Airtel and M&M.
Among losers, Maruti Suzuki, BHEL, Coal India, Axis Bank, Dr Reddy's Lab, HDFC Ltd, Sun Pharma, Adani Ports, Cipla, HDFC Bank and Hindustan Unilever fell by up to 2.02 per cent, which restricted the upside in the indices.
Sector-wise, the BSE auto index gained the most by surging 0.87 per cent, followed by technology 0.56 per cent, power 0.41 per cent, IT 0.40 per cent and banking 0.33 per cent.
Foreign investors net bought shares worth Rs 418.64 crore yesterday, showed provisional data.
On market outlook, Vinod Nair, Head-Fundamental Research,
Geojit BNP Paribas Financial Services, said: "A revival will depend on global developments like stabilisation in oil prices and the Chinese economy. On the domestic front, investors are cautiously looking forward to the Union Budget."
He added: "A speculative rally in Budget stocks like railway, consumer durables and the like cannot be ruled out."
The market breadth remained positive as 1,302 shares advanced, 1,204 lost while 136 ruled steady.