The Carlyle Group plans to invest in new energy technology to save a 140-year-old Philadelphia refinery and turn it into a profitable, state-of-the-art facility that the company hopes will continue to be the largest gasoline supplier on the East Coast.

The D.C.-based private-equity firm announced Monday that it will take majority ownership of Sunoco’s Philadelphia refinery, which Sunoco had planned to shut down next month, creating a new company called Philadelphia Energy Solutions.

Carlyle says the investment, which will give it two-thirds ownership of the new company, will preserve 850 jobs and add 100 to 200 permanent positions.

David Marchick, a Carlyle managing director, declined to discuss financial details or speculate on when the facility will turn a profit.

The venture seeks to exploit the vast U.S. reserves of oil and natural gas now available through new drilling technology. It came after months of difficult negotiations among a disparate group of parties, including Carlyle, Philadelphia-based Sunoco, the United Steelworkers union, members of Congress, a mayor, a governor and even the White House.

The refinery is the oldest continuously operating facility of its kind on the East Coast, processing 330,000 barrels of oil per day from West Africa and the North Sea into various petroleum-based products.

Rodney Cohen, a Carlyle managing director who headed the deal for the private-equity firm, said he plans to eventually replace the imported oil with U.S.-based crude oil from the Bakken field in North Dakota, as well as Montana and parts of Canada. The production from the Bakken field, which will be delivered to the Philadelphia plant via rail cars, has expanded in recent years because of new oil-drilling technology.

Carlyle, which is expected to invest several hundred million dollars while it owns the refinery, has had some success in the refinery business. It bought and sold a European refinery a few years ago, earning a fat profit.

Cohen is new to Carlyle, joining the firm less than a year ago after having engineered several turnarounds as an investor. He has teamed with Phil Rinaldi, another expert in the field, for the Philadelphia project.

The new project will include more than $200 million in capital investments, including $25 million in Pennsylvania state grants to help build a high-speed train to quickly unload the Bakken oil arriving from North Dakota.

The capital investments are expected to create more than 1,000 temporary construction jobs to improve the quality and yield of the fuel products and to reduce emissions.

Cohen said Carlyle is exploring a co-generation plant that would use the abundance of cheap natural gas from the huge Marcellus Shale formation under Pennsylvania and New York to help fuel the refinery, making it more cost-efficient.

He said technological advances in the transportation of Bakken oil and of natural gas make the project commercially feasible.

“We are going to explore a new range of energy and chemical businesses built on the foundation of abundant, Pennsylvania-sourced natural gas,” he said.

The deal, which was heading to a vote by the United Steelworkers union on Monday night, will also be financed by tax-exempt bonds and by JPMorgan Chase.

The Carlyle Group has $159 billion in assets under management and employs more than 1,300 people in 32 offices on six continents.