(Reuters) - Walmart Inc WMT.N, the world's largest retailer, will remain part of CVS Health Corp's CVS.N network for commercial and Medicaid pharmacy customers, the companies said on Friday, breaking a contract impasse disclosed earlier this week.

FILE PHOTO: An employee pushes shopping carts outside a Walmart store in Chicago, Illinois, U.S., November 20, 2018. REUTERS/Kamil Krzaczynski/File Photo

The companies did not provide financial terms of the new contract.

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

Walmart and CVS also said on Tuesday they were still in discussions.

CVS shares gained 1.6 percent to $64.76 in premarket trading, recouping some of the stock’s losses on Tuesday.

“We view the agreement positively for CVS,” Cantor Fitzgerald analyst Steven Halper said in a research note, explaining that the loss of Walmart pharmacies could have negatively impacted CVS’ ability to sign up customers for its 2020 prescription drug plans.

Evercore ISI analyst Ross Muken said the speed at which the dispute was resolved likely points to the negotiating strength of pharmacy benefit managers in contract discussions. Consumers historically move to where their insurance is accepted, and Walmart likely would have lost out on the estimated 15 million to 20 million prescriptions it receives from CVS customers, Muken said.

In 2012, Walgreens Boots Alliance WBA.O and pharmacy benefit manager Express Scripts, now part of Cigna Corp CI.N, failed to come to contract terms. Walgreens sales fell as it stopped filling prescriptions for Express Scripts customers, and the two companies reached a new agreement in the middle of the year that put Walgreens back in its network.

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 those on the government-run Medicare program were unaffected by the contract dispute as was its Sam’s Club agreements.

Sean Slovenski, a Walmart senior vice president, described the terms as “fair and equitable” in a press release.