By Devika Krishna Kumar and Jennifer Ablan

NEW YORK (Reuters) - Investors in junk-rated energy bonds, who have made a mint this year betting on this battered sector, are paring their holdings as oil flirts with sub-$40-a-barrel levels on concerns about a persistent overhang in supply and choppy demand.

Thanks to the two-year slump in the price of oil, energy debt securities yielded a whopping 21 percent in February when crude hit its lowest in over a decade at about $26. That brought in opportunistic buyers who watched prices rise, pushing yields to around 9.5 percent now, a level that these investors see as overvalued relative to oil's weakening price.

Energy debt prices have managed to continue to rally even as the price of oil headed lower in July, as investors believed that the bankruptcies that resulted from the two-year slump were largely behind the market.

U.S. crude futures <CLc1> settled on Tuesday below $40 for the first time since April, on heightened worries of a crude glut despite peak summer fuel demand. Oil lost nearly 15 percent in July, the biggest monthly loss in a year, triggering liquidation among bond investors.

Other bond investors who benefited from the recent risk-on rally in energy debt are paring holdings, viewing the massive run-up as an opportunity to take profits.

"We're neutral on energy bonds," said Dan Ivascyn, group chief investment officer at bond giant Pacific Investment Management Co, which oversees $1.5 trillion in assets. He said the firm is "cautious after their huge run," having moved to an underweight position in their high-yield holdings.

The BofA Merrill Lynch (BAML) U.S. High Yield Energy Index <.MERH0EN> posted a return of 26.7 percent from the start of the year through mid-July. Since then, though, the index is slipping, having dropped for 11 days straight, shedding about 3 percent in that period.

About 50 percent of the weight of this index is in double-B bonds, the highest-rated of junk debt. Those spreads are at 4.82 percentage points above comparable Treasury debt, yielding about 6 percent.

While still junk-rated, these securities reflect the lowest probabilities of default. Given that oil has dropped more than 20 percent from its June 9 peak, investors are finding it difficult to argue for real value for those bonds.

"You obviously regret the performance you missed, but a lot of these names are struggling and will continue to struggle," said Gregory Peters, senior investment officer at Prudential Fixed Income with more than $621 billion of assets. Prudential has some energy names but well under the index amount.

The BAML high-yield strategy team recommends a modestly overweight positioning in energy and within the sector, have an overweight target for exploration and production companies.

S&P Global Ratings in May said it expects corporate defaults to keep rising, dominated by energy companies. Between the start of 2015 and March 2016, the energy sector accounted for half of all corporate debt defaults in the United States.

Given expectations for continued low prices for oil and natural gas in 2016, this sector is expected by S&P Global Ratings to continue to dominate the default total, with the high likelihood of its proportion growing throughout the year.

One factor that has kept some investors positive on high-yield bonds is the notion that the current slump is not fully reflective of the fundamentals of oil.

While crude prices have been pressured by resurgent output and a glut in refined products, some analysts believe global supply and demand are roughly balanced, driven by steady declines in U.S. production.

Daniel Loeb's $16 billion Third Point LLC said that the bottom in oil was earlier this year. Last week, Third Point said its investments in energy credits drove positive returns during the first half of the year and it is devoting over $1 billion to energy corporate credits.

Third Point said it is currently focused on debt of "companies with high-quality assets and deleveraging catalysts where we can make good returns while limiting downside risk should commodity prices stagnate."

Societe Generale oil analyst Michael Wittner said he expects crude prices to bottom out in the high $30 range.

"We do not think that we will return to $35 or $30 or $26-27, as we saw in Q1 16," he said in a note.

(Reporting by Devika Krishna Kumar and Jennifer Ablan in New York; Editing by M Choy)