MUMBAI (Reuters) -The BSE Sensex and Nifty rallied to record highs on Tuesday as strong buying by foreign investors continued to bolster blue chips in the lead-up to general elections, especially companies more geared towards the domestic economy such as HDFC Bank.
Still, a bout of profit-taking erased most of the gains from earlier in the session as some technical indicators such as the relative strength index indicating overbought conditions.
A powerful rally over the past month and a half - with the Nifty up 7 percent since the end of January - has reflected hopes that the opposition Bharatiya Janata Party, perceived by markets to be more business friendly, would win elections that kick off next month, analysts have said.
A slight expansion in industrial output and a further cooling in stubbornly high inflation have also boosted investor sentiment, offsetting concerns about global risk factors, such as political tensions in Ukraine and China's economic slowdown, which have been weighing on stock markets elsewhere.
Goldman Sachs upgraded Indian shares to "overweight" from "marketweight", citing improving economic fundamentals and expectations that corporate earnings had bottomed out, recommending investors favour cyclical over defensive shares.
"Broadly it's all building up for elections, with (foreign) institutions continuously buying and creating positions," said Hansal Thacker, a director at Lalkar Securities.
"As the election nears, you will see more volatility in the markets. Profit-taking is expected at this level, but the undercurrent is firm."
The broader Nifty ended up 0.19 percent after earlier gaining as much as 1.1 percent to hit a record high of 6,574.95 points, surpassing its previous record high hit on March 11.
The BSE Sensex added 0.1 percent after earlier rising as much as 1.1 percent to an all-time high of 22,040.72 points, above its previous record hit on March 10.
Overseas funds were net buyers of $160.6 million worth of shares on Friday, marking their 20th net buying session in the previous 21, for a net total of $1.6 billion, exchange and regulatory data shows. Markets were closed on Monday for a public holiday.
Banks led gains on Tuesday, with Yes Bank Ltd (YESB.NS) rising 2.2 percent and State Bank of India advancing 2.9 percent.
Among other domestic-oriented blue chips, power equipment maker Bharat Heavy Electricals (BHEL.NS) gained 0.6 percent, while cigarette maker ITC (ITC.NS) rose 2.5 percent.
Shares of Maruti Suzuki Ltd (MRTI.NS) surged as much as 9.8 percent to a record high after it said on Saturday that it would seek minority shareholder approval for a plan to outsource production at a new factory to Japan's Suzuki Motor Corp (7269.T). Shares closed 7.46 percent higher.
Shares in AstraZeneca Pharma (ASTR.NS) gained 2.6 percent after the company said its board had approved a proposal from promoter AstraZeneca Pharmaceuticals AB, Sweden, to delist the company from India.
Still, investors also booked profits in some recent outperformers. ICICI Bank (ICBK.NS) fell 0.9 percent after earlier gaining as much as 1.3 percent, though shares in India's biggest private sector lender are still up 15.4 percent so far this month.
Software service exporters were among the losers, continuing a trend in which they have fallen out of favour compared with domestic-focused shares. Tata Consultancy Services Ltd (TCS.NS) fell 0.8 percent, bringing its losses so far this month to 6.8 percent.
(Editing by Kim Coghill and Pravin Char)