By John Kemp

LONDON, July 3 (Reuters) - Hedge fund managers had amassed a record number of short positions in petroleum futures and options by the start of last week, which primed the oil market for a sharp short-covering rally at the end of the month.

Hedge funds and other money managers held short positions in the five major contracts on crude, gasoline and heating oil amounting to 510 million barrels on June 27, according to regulatory and exchange data.

Fund managers have added 200 million barrels of extra short positions since the end of May and 377 million barrels since crude prices peaked in the middle of February.

Hedge funds were even more pessimistic than in January 2016, with more short positions than when oil prices were touching their cyclical lows below $30 per barrel.

Overall, fund managers were running net short positions of 20 million barrels in gasoline and 32 million barrels in heating oil on June 27.

Funds still had a net long position of 357 million barrels in crude but it had been cut from 589 million barrels on May 30 and a record 951 million barrels on Feb. 21.

Growing doubts about the effectiveness of OPEC's production cuts, coupled with increases in crude output from Libya, Nigeria, Canada and the United States have prompted a wave of short-selling.

And concerns about the health of gasoline demand and high level inventories in the United States have added to the bearishness within the hedge fund community.

Fund managers have ramped up short positions in NYMEX WTI by 86 million barrels over the last four weeks, in the most aggressive short-selling cycle since the start of 2015.

But the sheer number of short sales left the market looking imbalanced and vulnerable to a short-covering rally ("Hedge funds hold near-record short positions in petroleum", Reuters, June 27).

Crude prices have now risen for seven consecutive trading sessions as the pace of short sales slows and some hedge fund managers have been emboldened to start adding long positions in anticipation of a rally.

Hedge funds quietly added 3 million barrels of extra long positions in gasoline, 0.7 million in heating oil and 9 million in WTI in the week to June 27 (though this was offset by a continued reduction of 20 million in Brent).

Fund managers are likely to have closed out at least some of their short positions as prices have risen consistently over the last week.

The U.S. oil rig count fell slightly last week for the first time since early January which accelerated the short covering and provided a boost to oil prices at the end of the week.

The critical question for the market is how many of those short positions have been closed out and how many more are still open.

If many of the extra short positions have been closed, prices are likely to stabilise around current levels, but if most remain open, upward pressure is likely to continue.

(Editing by Susan Thomas) ((john.kemp@tr.com; +44 207 542 9726 and on twitter @JKempEnergy))