Oil and gas producer Anadarko Petroleum said on Thursday it would sell nearly all of its midstream assets, including pipelines, to its master limited partnership Western Gas Partners for $4.02 billion.

The company is selling assets in the Permian basin in Texas and New Mexico, and the DJ basin in Colorado.

Western Gas will take complete ownership of DBM Oil Services, and APC Water Holdings, while acquiring a 50 percent stake in multiple gas plants in the Delaware basin of West Texas, the companies said.

The sale is expected to close in the first quarter of 2019.