Sunoco Logistics Partners LP has agreed to acquire Energy Transfer Partners LP (ETP) in an all-stock deal valued at nearly $20 billion in a tie-up that would create the nation’s second largest midstream master limited partnership by enterprise value.

The deal, the companies said, would bolster scale and diversity across several of the country’s onshore basins and provide more opportunity to integrate Sunoco’s natural gas liquids (NGL) business with ETP’s gas gathering, processing and transportation business. It comes about four years after ETP acquired Sunoco Inc. in a $5.3 billion deal aimed at giving the midstreamer a stronger hand in moving heavier hydrocarbons such as crude oil, NGLs and refined products.

Under the agreement, which is expected to close in 1Q2017, ETP unitholders would receive 1.5 common units of Sunoco for each common unit of ETP they own. The deal values those units at about $39.30 each, or just under ETP’s Friday closing price of $39.37, but a 10% premium to the average price of those units over the last 30 trading days. The deal is valued at $19.93 billion and must be approved by ETP unitholders.

The announcement comes after a dramatic year for ETP, in which its efforts to acquire the Williams Companies Inc. failed and a fight with the Standing Rock Sioux Tribe and the federal government over the delayed Dakota Access oil pipeline has attracted the nation’s attention.

Sunoco and ETP said they expect the merger to provide cost savings of more than $200 million annually by 2019. It would also strengthen the balance sheet of the business by utilizing distribution savings, or the payments to unitholders from available cash flow, to reduce debt and fund a portion of capital expenditures. The companies have spent a combined $15 billion on growth projects in recent years.

Energy Transfer Equity LP would own the distribution rights of Sunoco after the deal closes. It would continue providing all the incentive distribution right subsidies in effect and the combined partnership is expected to achieve near-term distribution increases in the low double digits.

ETP’s current management team would take the helm of the new partnership. Kelcy Warren, Mackie McCrea, Matt Ramsey and Tom Long, would serve as CEO, chief commercial officer, president, and CFO, respectively. Sunoco’s current CEO, Mike Hennigan, and other members of the company’s executive management team would stay on and work in leadership roles from Sunoco’s headquarters in Philadelphia.

Both companies have been working simultaneously to keep pace with growth and expand their footprints in areas such as the Southwest and the Appalachian Basin. A stronger balance sheet could aid Sunoco with its own challenges, such as the permitting delays and opposition to its Mariner East 2 pipeline project, which would move ethane, butane and propane from processing and fractionation complexes in Ohio, Western Pennsylvania and West Virginia to the Marcus Hook Industrial Complex near Philadelphia for distribution to domestic and international markets. Share prices of both companies closed down about 7% on Monday, despite a day of broader gains for the markets.