U.S. utility owner Sempra Energy (NYSE: SRE) has agreed to buy control of Texas power distributor Oncor Electric Delivery Co. for $9.45 billion, topping a bid by Warren Buffett’s Berkshire Hathaway Inc. just last month.

Sempra’s deal for Energy Future Holdings Corp., which owns 80 percent of Oncor, is valued at about $18.8 billion including debt, the San Diego-based company said in a statement. Sempra plans to fund the purchase through a combination of its own debt and equity, as well as third-party equity and $3 billion of borrowings by the reorganized company, it said.

Just six weeks ago, Berkshire struck a deal to buy Oncor for $9 billion. Shortly after, billionaire investor Paul Singer’s Elliott Management Corp. fired back, saying it was working to pull together a rival bid that may total $9.3 billion.

Elliott voiced its support of the Sempra deal, saying in an emailed statement it provides “substantially greater recoveries” to all Energy Future creditors than Berkshire’s offer.

Sempra is the latest to join a line of suitors who’ve sought to take over Oncor since its parent Energy Future declared bankruptcy in 2014. The deal may put an end to the escalating battle between Buffett and Singer and would be Sempra’s largest acquisition since it was formed in 1998, based on data compiled by Bloomberg, expanding its U.S. utility territory beyond California.

Sempra received financing commitments for the deal from RBC Capital Markets and Morgan Stanley, it said in its statement. It expects the transaction to be completed in the first half of 2018. Lazard and Morgan Stanley advised Sempra, with White & Case LLP acting as legal advisers, it said.

The deal is key to ending Energy Future’s bankruptcy, which has now spent more than three years working to restructuring almost $50 billion of debt. A judge was scheduled to consider Berkshire’s offer during a U.S. bankruptcy court hearing in Wilmington, Delaware.

The merger agreement with Berkshire included a termination fee of $270 million, subject to certain conditions and court approval, according to a regulatory filing. Berkshire has said it’ll walk away from the deal if a judge doesn’t approve the plan.

Others have tried and failed to take over the Texas utility, which serves almost 10 million customers and operates more than 106,000 miles (170,590 kilometers) of distribution lines.

Earlier this year, Texas utility regulators quashed an offer from NextEra Energy Inc., valued at $18.4 billion including debt, after the utility giant refused to establish ring-fencing measures to protect Oncor’s credit. A group led by Hunt Consolidated dropped a bid last year after the state imposed conditions it found too onerous.

“It’s not just a question of what you’re offering -- it’s a question of whether or not it’s going to make Texas regulators feel comfortable enough to allow the deal,” Paul Patterson, a utilities analyst at Glenrock Associates LLC in New York, said by phone. “And we’ve already seen two fail in this situation.”

Sempra said in its statement announcing the deal that it “will maintain the existing independence of Oncor’s board of directors, which has protected Oncor and its customers during the ongoing Energy Future bankruptcy.”

Energy Future was formed a decade ago by KKR & Co., TPG Capital and Goldman Sachs Capital Partners as part of the biggest leveraged buyout in history. It sought protection from creditors after natural gas plummeted, dragging down wholesale prices for the power the company was generating.

Sempra runs power and gas utilities in Southern California, Chile and Peru that altogether serve more than 32 million consumers, according to the company’s website. It also owns and operates almost 2,400 megawatts of renewable energy capacity with partners; the Mexico pipeline developer IEnova; and a liquefied natural gas export terminal project in Louisiana with partners.

Last year, Sempra pulled out of talks to buy a stake in a planned $6.5 billion natural gas pipeline project in Peru after the country’s government refused to a remove a condition but has since said it may re-bid for the project. In December, the company’s IEnova unit bought wind power assets in Mexico for about $900 million, including debt.

Elliott recently bought debt in Oncor’s parent in its latest effort to block Berkshire’s bid, people familiar with that matter said. Buying the notes means Elliott and and Sunrise Partners, which also opposes Berkshire’s offer valued at $18.2 billion with debt, own the majority of every class of impaired credit in the holding company, one of the people said. That might allow Elliott to block the Berkshire deal as a so-called dissenting impaired class of creditor under bankruptcy law.