Brent crude futures settled up 29 cents, or 0.6 percent, at $45.83 a barrel. The benchmark was still set to end the first half of the year down nearly 20 percent.

U.S. crude futures were up 37 cents, or 0.8 percent, at $43.38 a barrel.

"I think it’s mostly bottom fishing at this point," said John Kilduff, partner with energy hedge fund Again Capital in New York, who noted there was some "book squaring" with the end of the quarter approaching.

"After how much we’ve fallen, prices are attractive here as a result, so it’s not surprising that we're getting some buying, just on a valuation perspective."

In the week to June 20, investors in U.S. crude futures and options increased their short positions, or bets against rising prices.

"On a speculative basis it’s arguably worth going long here and playing for a bounce," Kilduff said. "The market is taking a breather here before we take a next move, which I think will be lower."

The Organization of the Petroleum Exporting Countries and its partners have been trying to reduce a global crude glut with production cuts. OPEC states and 11 other exporters agreed in May to extend cuts of 1.8 million barrels per day (bpd) until March.

However, Nigeria and Libya, OPEC members exempt from the cuts, have raised output. Iran was allowed a small increase to recover market share lost under Western sanctions. It said its production has surpassed 3.8 million bpd and is expected to reach 4 million bpd by March.

U.S. shale oil output is up around 10 percent since last year, with the number of U.S. oil rigs in operation at the highest in more than three years.

“U.S. production could jump to 10, maybe 10.5 million barrels a day by the end of the year, and when you add Libya, Nigeria and North Sea production, that will negate the Saudi-led cuts," said Gene McGillian, manager of market research at Tradition Energy in Stamford, Connecticut. "We’re looking to make a run at the 40 dollar market."

Analysts at Bank of America-Merrill Lynch said demand had not grown quickly enough to absorb excess output.

"Looking into the second half of 2017, we now doubt that demand growth will accelerate sufficiently," they wrote.

(Additional reporting by Amanda Cooper in London, Jane Chung in Seoul; Editing by David Gregorio and Steve Orlofsky)

By Julia Simon