Targa Resources Partners and Targa Resources Corp. announced Monday an agreement to acquire natural gas and oil company Atlas Energy and its midstream subsidiary, Atlas Pipeline Partners, in a transaction valued at about $7.7 billion.

Targa Resources Partners, a provider of midstream natural gas and natural gas liquid services, will purchase Atlas Pipeline Partners for a total of $5.8 billion, which includes $1.8 billion of debt. Targa Resources Corp., a holding company of midstream energy assets, will subsequently buy Atlas Energy for about $1.9 billion after Atlas Energy spins off its nonmidstream assets, which include four pipeline systems and 17 processing plants to treat oil, natural gas and natural gas liquids.