The inventory of refined products has come down in recent months, offering a glimmer of hope to refiners, whose margins fell sharply in 2016 due to a glut of gasoline and diesel.

Valero, the biggest among U.S. oil refiners, benefited, with its first-quarter results beating market expectations on Tuesday as sales in its refining business surged 40 percent.

"With VLO being the first out of the gate and the bellwether for refining, we believe the stronger-than-expected (refining and marketing) results, strong export volumes and bullish market commentary could start setting the pace for improved investor sentiment towards the sector," Morgan Stanley said in a client note.

However, high costs for renewable fuel credits would be 'a significant headwind' in the second quarter of 2017, Chief Executive Joe Gorder said on a post-earnings call.

The cost refiners pay for credits to meet environmental regulations for biofuel use has surged, adding fuel to a debate over who pays for the rising costs.

Valero's shares rose 1.3 percent in morning trading, before reversing course to trade down about 2 percent at $65.39.

Valero processed more barrels of crude oil than it expected to in the first quarter, pushing down operating costs, and said it would ramp up activity.

"(Strong demand) combined with expectations for continued sweet crude oil production growth and relatively low prices for crude and refined products, consumer demand should be robust this year," Gorder said.

Valero's refineries processed 2.8 million barrels per day in the quarter, compared with its estimate of 2.7-2.8 million barrels.

That helped the company's operating cost to average $3.85 per barrel, lower than its estimate of $4.15.

Valero expects to process 2.9-3.0 million barrels per day in the second quarter, said John Locke, vice president of investor relations at the company.

Operating revenue in Valero's refining business soared 40 percent to $20.89 billion in the first quarter.

That helped the company's total operating revenue jump 38.6 percent to $21.77 billion, beating analysts' average estimate of $18.59 billion, according to Thomson Reuters I/B/E/S.

Net income attributable to Valero's shareholders fell 38.4 percent to $305 million. Excluding items, the company earned 68 cents per share, beating analysts' estimate of 60 cents.

(Reporting by Muvija M in Bengaluru; Editing by Maju Samuel and Savio D'Souza)