A Texas pipeline company, Energy Transfer Partners L.P., announced Monday that it would buy Sunoco Inc. for $5.3 billion, the latest turn in the dramatic transformation of the iconic 126-year-old Philadelphia oil business.

Energy Transfer (ETP), based in Dallas, said it would acquire Sunoco for a combination of cash and stock.

The Philadelphia retailer of motor fuels and its pipeline affiliate, Sunoco Logistics Partners L.P., will maintain their headquarters in the Philadelphia area, company officials said. An ETP official said the "vast majority of Sunoco management team and employee base will remain in place."

Sunoco said its plans to exit the refining business, announced last year, were unchanged. Last week, the company announced that it was pursing a joint venture with the Carlyle Group to run its Philadelphia plant, its last operating refinery, and that it would shut down the refinery Aug. 1 if it were unable to consummate a deal with the private-equity firm.

Sunoco's sale, which is expected to close later this year, would mark the latest departure of a Fortune 500 company from Philadelphia. Only Comcast, Aramark, and Crown Holdings still maintain corporate headquarters in the city.

"Our commitment to the area also remains unwavering," said Brian P. MacDonald, who became Sunoco's chief executive two months ago. "We will continue to have a key presence in the region."

Despite Sunoco's storied history as a refiner and marketer of petroleum, and as a global exploration company that generated the wealth that funded the Pew Charitable Trusts, the company's greatest attraction in the end came down to its vast network of pipelines and fuel-storage facilities operated by Sunoco Logistics.

Energy Transfer, whose primary business is transporting natural gas from Gulf Coast producers, values Sunoco Logistics' experience moving crude oil. Sunoco Logistics also has a footprint in the Marcellus Shale region, where pipeline and processing companies are scrambling to capitalize on the growing production of natural gas and liquid fuels.

"The Marcellus is the real deal," Kelcy L. Warren, chairman and chief executive of Energy Transfer, said in an interview Monday. There are "huge opportunities" for industry to reconfigure pipeline networks to move fuel out of emerging natural-gas and oil fields, such as the Marcellus, he said.

Sunoco's retail business, built around its network of 4,900 fuel outlets, will account for only 10 percent of earnings in the new company. During a conference call with investment analysts on Monday, some questioned whether Sunoco's retail network would have a long-term home with ETP.

"I think everyone knows we would not have targeted a retail business for a strategic move for the company," Warren said. "However, it is part of the overall package of what we're buying here."

He said Sunoco's retail operation was well-run and sustainable. "We're happy to have it, and we're committed to the business, and we will continue to grow it and manage it with the people who have done so well doing it for quite a while."

MacDonald said ETP has little experience in the areas in which Sunoco has specialized and planned to retain Sunoco's institutional expertise. "The operating management and the substantive teams in those businesses will stay in place," he said.

He acknowledged that "there will be some corporate overhead reductions," although most of the $70 million in synergies envisioned by the merger will come from new commercial opportunities.

"And as part of a stronger company with increased stability and scale to capitalize on growth opportunity, we believe Sunoco will be even better positioned to return economic benefit to the Philadelphia region and to the other areas of operation," MacDonald said.

Sunoco, founded in 1886 by Joseph Newton Pew and Edward O. Emerson, grew into a worldwide integrated oil company during the automobile age, when it explored for oil, and at one point it developed a huge shipbuilding operation in the Philadelphia area.

But the company has been transforming itself for decades - it got out of oil exploration and Canadian oil-sands production more than 20 years ago. Under former chief executive and current chairwoman, Lynn Elsenhans, it divested its chemical and metallurgical coke businesses.

In the fall, it announced plans to exit its last production business, refining, which had tallied $1 billion in losses in the last three years.

Warren said his company became interested in Sunoco while it was holding talks with Sunoco Logistics about engaging in a joint venture to convert an ETP natural-gas pipeline to deliver crude oil.

"That evolved, and we learned more about Sunoco Logistics and then, later, through some contacts that I had, asked to have a meeting with Brian," Warren said.

He visited Philadelphia about two months ago, "just kind of talked philosophy, talked chemistry, and if it would ever make sense to put these two companies together."

The buyer will pay about $50.13 a share, or 29 percent premium above Sunoco's average 20-day closing price. The merger, approved by both boards, will consist of $25 in cash and 0.5245 of an ETP common unit - about half cash, half shares.

Sunoco's shares soared on the news, which was announced before markets opened, and closed at $49.29, up $8.38 or 20.5 percent. ETP's units closed at $49.63, up $1.71 or 3.6 percent, on the New York Stock Exchange.

ETP will own Sunoco's general-partner interest in Sunoco Logistics, which controls the pipeline company and generates a lucrative incentive distribution for the parent company. ETP also will acquire Sunoco's 32.4 percent interest in Sunoco Logistics' partnership units, which will continue to be traded separately on the New York Stock Exchange.

Energy Transfer's corporate status as a master limited partnership will present a challenge for some Sunoco investors. With MLPs, investors buy units of the partnership rather than shares. Distributions are reported differently and taxed differently from dividends and may not be suitable for some investors or in retirement accounts.

ETP officials said Sunoco shareholders would have an option of taking some or all of their settlement in cash or units.

Energy Transfer's assets are concentrated primarily in natural-gas pipelines along the Gulf Coast, and it has expressed a desire to diversify into transporting crude oil and refined fuels.

Sunoco Logistics' pipelines tie together its former refinery network in Philadelphia, Ohio, and Oklahoma to crude-oil fields in Texas.

Though the merger won't alter Sunoco's plans to divest the Philadelphia refinery, MacDonald said it may provide new opportunities for Sunoco's refinery in Marcus Hook, idled late last year.

No potential buyers have expressed an interest in operating Marcus Hook as a refinery, MacDonald said. "We do have a number of options that we're looking at for repurposing the site, and quite frankly, we think being part of the Energy Transfer family of partnerships will give us some additional options."

Read recent coverage of Sunoco at http://www.philly.com/sunoco