US oil settles up 21 cents, or 0.4%, at $50.36 a barrel

An oil pump jack in Gonzales, Texas.
Getty Images

Crude oil futures rose modestly after a volatile trading session as the U.S. front-month August contract headed to expiration on Tuesday, with the weaker dollar providing support.

U.S. August crude, set to expire on Tuesday, closed up 21 cents, or 0.4 percent, at $50.36 a barrel.

Front-month August crude dropped below $50 on Monday for the first time since April and the front-month price is down 15 percent in July. Brent crude for September was 30 cents higher at $57 a barrel, having swung from $56.33 to $57.44. Brent's premium to September U.S. crude was near $6 a barrel.

Weak U.S. RBOB gasoline futures curbed gains for crude, especially Brent, traders said, as expectations that inventories rose again last week as refiners continue to operate at a high utilization rate weigh on prices.

The dollar retreated from a three-month high against a basket of currencies on mild profit-taking.

Read More Oil rebound? These banks think so

A rising dollar makes it more profitable for non-U.S. investors to sell dollar-denominated assets and a weaker greenback makes oil less expensive for consumers using other currencies.

"Seems like there is volatility with the U.S. August contract set to expire and the weak equities are not helping either," said John Kilduff, partner at Again Capital LLC in New York.

Expectations of more Iranian supply following last week's agreement on Tehran's nuclear program and concerns that economic worries in China and Europe will weigh on demand have put pressure on oil this month.

Futures Now: Crude snaps 4-day losing streak

"August WTI is a particular focus of attention ahead of today's expiration and we expect much gravitation at around the $50 mark," Jim Ritterbusch, president at Ritterbusch & Associates in Galena Illinois, said in a note.

Read MoreAlberta spill heaps pain on Canada's oil sector

U.S. August RBOB was slightly off at $1.9021 a gallon, as it trades between its 100-day moving average of $1.9524 and its 200-day moving average at $1.8591.

U.S. gasoline stocks were expected to have risen 1 million barrels last week, according to analysts surveyed by Reuters on Monday ahead of the weekly industry and government inventory reports due respectively late Tuesday and on Wednesday.

Crude oil stocks were expected to have fallen 2.1 million barrels.

"Fifty dollars is almost a fault line for bulls and bears to battle it out, but if you want to choke off U.S. production, that price may have to move a bit lower. With $50 being that support level, this is where we will get some buying coming in," BNP Paribas analyst Harry Tchilinguirian said.