The BSE benchmark Sensex ended in green for the fifth consecutive week on persistent buying mainly in realty, banking and metal counters, on the back of good capital inflows.
Expectations of measures from the government for reviving a slowing economy also boosted the market sentiment.
Continued buying in small-and mid-cap shares by retail investors played a major role in extending the rally. The BSE Mid-Cap index rose by 2.60 per cent, while BSE Small Cap index gained 4.26 per cent, outperforming the Sensex.
Special:Can fortune tellers predict stock markets?
The 30-share Sensex rose 91.14 points, or 0.52 per cent, to end the week at 17,521.12. The S&P CNX Nifty of NSE gained 38.05 points, or 0.72 per cent, to settle at 5,316.95.
Sensex has gained 1,555.96 points, or 9.75 per cent, in the last five weeks, while the 50-unit Nifty firmed up by 475.35 points, or 9.82 per cent, in the same period.
Foreign Institutional Investors (FIIs) have bought shares worth net Rs 4,755.70 crore in July 2012 so far (till July 4).
Prime Minister Manmohan Singh, who also holds the Finance portfolio, said last month that he is chalking out plan for the country's economic revival.
"Strong FII fund flows and expectations of measures from the government to boost the sagging economy helped the market to remain firm," said Alex K Mathews, Head-Technical and Derivatives Research, Geojit BNP Paribas Financial Services.