Walgreen on Monday announced it had extended its agreement to buy rival drugstore chain Rite Aid in exchange for at least a 22 percent discount in the purchase price.

For 15 months, Walgreen, led by CEO Stefano Pessina, has been trying to win regulatory approval to buy its competitor, which would create the biggest US drugstore chain, surpassing CVS.

The merger agreement between the chains expired Friday.

Walgreen announced the purchase price will be cut from $9 a share to $7 a share if it needs to sell 1,000 or fewer Rite Aid stores to gain approval. It said it will cut the price to $6.50 if regulators force a sale of up to 1,200 stores.

In exchange, Walgreens extended the merger agreement to July 31.

If Walgreen had walked away from the deal, Rite Aid’s share price could have fallen below $4 a share, sources said.

The Federal Trade Commission has raised concerns about the current plan to sell 850 Rite Aid stores to regional pharmacy chain Fred’s.

The worry is that Fred’s may not be able to restore competition in the areas where the stores will be sold because it will be forced to take on a heavy debt load to complete the $950 million deal.

Fred’s shares were up 1.3 percent, to close at $14.29, on Monday — the day the new deal was announced.

The Post reported exclusively on Friday that Cerberus Capital Management, through its supermarket chain Albertsons, would like to replace Fred’s as the buyer of the divested stores.

Last week, Supermarket News reported that Albertsons called off its effort to buy the Schenectady, NY, Price Chopper supermarket chain. There is speculation that this may be because Cerberus believes it’s getting closer to acquiring Rite Aid stores.

“It seems like Walgreen needs to sell more than the 865 stores it is selling to Fred’s,” a source following the situation said, explaining why the new Rite Aid merger agreement calls for Walgreen to sell up to 1,200 stores, an increase from the prior 1,000 maximum.

Walgreen, perhaps expecting to sell more stores than anticipated — in order to get regulatory approval — pushed for the lower deal price, the source said. The more stores it sells, the more dilutive the deal becomes.

“Rite Aid had zero, zero leverage” in the negotiations, the source said, as Rite Aid, helmed by CEO John Standley, could not afford to let Walgreen walk away.

“To the extent the Federal Trade Commission requests that additional stores be sold, and Walgreens agrees to sell such stores, Fred’s Pharmacy has agreed to buy those stores. The amendment and extension of the merger agreement reinforces the company’s confidence that the transaction is in the mutual best interest of Fred’s Pharmacy and all of its shareholders,” a Fred’s spokesman said.