CVS Health Corp and Walmart Inc said on Friday the world's largest retailer would remain part of CVS's network for commercial and Medicaid pharmacy customers, breaking a contract impasse CVS disclosed earlier this week.

Financial terms of the new contract were not disclosed.

On Tuesday, CVS said the companies had failed to agree on pricing and that Walmart was leaving the pharmacy network for the prescription drug plans that CVS manages for companies and health insurers and for the Medicaid program for low income people.

The companies said on Tuesday they were still in discussions.

In addition to its retail pharmacies and stores, CVS is one of the country's biggest pharmacy benefit managers and, after buying Aetna, one of its top health insurance companies. Its prescription plans for the Medicare population were unaffected by the contract dispute as was its Sam's Club agreements.

Walmart senior vice president Sean Slovenski described the terms as "fair and equitable" in a press release. (Reporting by Caroline Humer in New York and Ankur Banerjee in Bengaluru; Editing by Shounak Dasgupta and Chizu Nomiyama)