(Reuters) - Utility Sempra Energy said on Monday that it would buy Oncor for $9.45 billion in cash after majority owner Energy Future Holdings Corp abandoned a deal to sell the power transmission company to Warren Buffett’s Berkshire Hathaway Inc.

This represents a rare blow to Buffett, who avoids bidding wars for companies and had swooped in two months ago to buy Oncor after Texas regulators blocked two previous attempts by Energy Future to sell it.

Energy Future, which has been in bankruptcy since 2014, had initially planned to seek court approval on Monday for the sale of Oncor to Berkshire for $9 billion over opposition from its biggest creditor, hedge fund Elliott Management Corp. Instead, Energy Future lawyer Chad Husnick told the court the Dallas-based company had decided to “pursue another path” with Sempra because of the value of the bid, a lower break-up fee and, most importantly, support from Elliott.

San Diego-based Sempra said it expected to own about 60 percent of a reorganized Oncor after it completes the transaction, which is valued at $18.8 billion, including debt. Energy Future owns 80 percent, but Sempra plans to sell some of that equity to other outside investors, according to people familiar with the matter.

Sempra’s shares were up 1.2 percent at $117.79 after hitting an all-time high of $118.78 on Monday after the company said the deal would add about 10 million of Oncor’s Texas customers to its base and increase its earnings starting next year.

“They get to own 60 percent interest in a quality, growing Texas distribution utility,” said Gabelli & Co analyst Timothy Winter. “It’s a way for them to grow in a low-risk manner.”

Utilities have become wary of their exposure to volatile energy prices and see power generation operations becoming less lucrative. Many of these companies are now hungry for electricity distribution assets, which have a growing demographic base and stable cash flows.

FILE PHOTO: Berkshire Hathaway CEO Warren Buffett visits the BNSF booth before the Berkshire Hathaway annual meeting in Omaha, Nebraska, U.S. May 6, 2017. REUTERS/Rick Wilking/File Photo

“On the face of it, the transaction continues the long line of industry consolidation, which we continue to view as expensive,” Morningstar analyst Andrew Bischof wrote in a note.

Elliott had tried to put together its own bid for $9.3 billion to buy Oncor but ultimately decided to back the Sempra deal, which a spokesman said “provides substantially greater recoveries to all creditors of Energy Future than the proposed Berkshire transaction.”

Berkshire, which bid for Oncor as part of its pursuit of steady profits from utilities and infrastructure deals, had said last week it would not raise its offer. In response to Sempra’s move, however, Berkshire said it would allow Energy Future to keep an Oncor dividend, but that proposal was not enough to bridge the gap in price, according to the sources.

Judge Christopher Sontchi told the bankruptcy court on Monday that the new bid was a “big change” that would clearly benefit Energy Future and its creditors.

“We are disappointed our agreement to acquire Oncor has been terminated,” Greg Abel, the chief executive officer of Berkshire’s energy unit, said in a statement. Many investors consider Abel a top candidate to eventually succeed Buffett, 86, at the Omaha, Nebraska-based parent company’s helm.

A hearing on the revised reorganization plan and creditor support agreement was set for Sept. 6 in U.S. Bankruptcy Court in Delaware. With Elliott’s support, Sempra is likely to get court approval for the deal.

The deal calls for Oncor General Counsel Allen Nye to become the company’s CEO, succeeding Bob Shapard, who becomes executive chairman.

Canadian pension fund manager Borealis Infrastructure Management Inc and Singapore sovereign wealth fund GIC Special Investments Pte Ltd currently own 20 percent of Oncor.

Lazard Ltd and Morgan Stanley are financial advisers to Sempra, and White & Case LLP is its legal adviser. Evercore Partners Inc is the financial adviser to Energy Future, and Kirkland & Ellis LLP is its legal adviser.

RBC Capital Markets and Morgan Stanley committed to invest $3 billion of expected investment-grade debt for the recapitalization of Oncor.