The Sensex surged 623 points or 1.61 per cent to close at 39,435 and the NSE Nifty 50 Index advanced 187 points or 1.6 per cent to end at 11,844.

"The markets are rallying on hopes that after BJP improved on its 2014's tally of 282 seats will deliver on structural economic reforms, increase spending on infrastructure and announce another recapitalisation plan for state-run banks," AK Prbhakar, head of research at IDBI Capital Markets told NDTV over phone.

Gains in ICICI Bank, HDFC Bank, Larsen & Toubro, State Bank of India and Infosys alone contributed over 350 points towards rally in the Sensex.

Buying was visible across sectors as all the 11 sector gauges compiled by National Stock Exchange ended higher led by the Nifty PSU Bank Index's 5.6 per cent surge.

Nifty Bank, Auto, Financial Services, Metal, Private Bank and Realty sector gauges also climbed between 2 and 4 per cent each.

Mid- and small-cap shares also witnessed buying interest as the S&P BSE MidCap Index climbed 2 per cent and the S&P BSE SmallCap Index advanced 2.4 per cent.

With NDA coming back into power we can expect local investors to take comfort in the mid and small-cap space with a longer 2-3 year horizon and inflows could resume in them, Kotak Securities said in a report.

In the Nifty 50 basket of shares, 45 ended higher while only five shares closed lower. ICICI Bank was top Nifty gainer, the stock surged as much as 5.5 per cent to hit a fresh 52-week high of Rs 433.55. Vedanta, Tata Steel, Bharti Airtel, Zee Entertainment, Larsen & Toubro, Mahindra & Mahindra, Tata Motors and Hero MotoCorp were also among the gainers.

On the flipside, Tech Mahindra, NTPC, Tata Consultancy Services, ONGC and HCL Technologies were among the notable losers.