The Sensex rose by 19.30 points, or 0.10 per cent, to close at 19,784.08. In last three-day rally, the gauge had climbed to its highest level since January 2011.
The broad-based National Stock Exchange index Nifty gained by 6.65 points, or 0.11%, to 6,016.15, after touching the day's low of 5,981.55.
Brokers said the fundamentals of the market were strong and kept the investor confidence higher even as the global markets remained under pressure after senior Federal Reserve officials expressed concerns about continuing to expand stimulative bond buying.
They said the initial losses were removed as state-owned oil companies rose on expectations the government could soon raise diesel prices and a pricing formula might help sharply raise the prices of domestic natural gas.
"Expectations of rise in diesel prices triggered rise in oil retailers such as HPCL, BPCL and IOC. Other Oil and gas stocks in the Nifty also saw buying interest viz. cairn and ONGC. The rise in the markets was also supported by the IT stocks, which remained buoyant along with the strength in dollar rates," said Milan Bavishi, Head Research, Inventure Growth & Securities.
Besides weak global trend, steep fall in base-metal prices in the overseas markets also put pressure on the market to some extent, they added.
In 30-BSE index components, 16 stocks ended with gains led by Reliance Industries, Infosys, ONGC, Gail, ICICI Bank, State Bank of India and BHEL. The oil and gas and IT sector stocks remained star-performers.
The investors focus was seen shifting to mid-cap and small-cap sectors for a quick return.