Take that, regulators.

With questions swirling whether its combination would get approved by regulators, Walgreens Boots Alliance (WBA) and Rite-Aid (RAD) struck a clever deal on Thursday. Walgreens will pay $5.175 billion to Rite-Aid in cash and receive 2,186 stores in return. Walgreens will also pay Rite-Aid a $325 million termination fee for its planned buyout of the company.

Walgreens will be an even bigger drug-selling beast, with more than 15,000 stores spanning 11 countries. As for Rite-Aid, it will be left with about 2,300 stores once the deal closes in six months.

"I view this deal as being more attractive...the deal is expected to give us significant benefits," said Stefano Pessina, Walgreens Boots Alliance executive vice chairman and CEO, on an earnings call with analysts.

Pessina said, after "detailed discussions with Rite Aid," both parties agreed that the merger would likely not pass with regulators, so they struck the new deal.

"Where there is a will, there is a way," Pessina said on the call, adding that for Walgreens, the "change brings opportunity" for new partnerships.

While largely overshadowed by its merger termination, Walgreens Boots Alliance did report third-quarter earnings this morning, too. The company posted earnings of $1.33 a share on revenue of $30.1 billion, beating Wall Street's estimates for earnings of $1.30 a share on revenue of $29.7 billion.

Shares of Walgreens rose 0.3% to $77.35 early Thursday afternoon. Rite-Aid dropped 28% to $2.85.

Fred's (FRED) stock crashed 19% to $9.97 as it will be shut out of buying 865 stores the combined company planned to divest.

"While the acquisition of additional stores was an opportunity for growth, we always viewed it as a potential outcome that would accelerate our transformation, not define it," Fred's CEO Michael Bloom said. "This is a disappointing outcome; however, the termination of the transaction has no impact on the Company's transformation strategy or our ability to execute."

Walgreens Boots Alliance is a holding in Jim Cramer's Action Alerts PLUS Charitable Trust Portfolio. Want to be alerted before Cramer buys or sells WBA? Learn more now.

Visit here for the latest business headlines.

Read More Trending Articles:

More from Stocks

Nvidia Wipes Nearly $25 Billion From Its Market Cap After Earnings Day Disaster

Nvidia Wipes Nearly $25 Billion From Its Market Cap After Earnings Day Disaster

Facebook Stock Slides Another 3% as Woes Continue

Facebook Stock Slides Another 3% as Woes Continue

Chart of the Day: How Jerome Powell Could Shift the Semiconductor Landscape

Chart of the Day: How Jerome Powell Could Shift the Semiconductor Landscape

Flashback Friday: Nvidia Is the Ultimate Chip and Dip

Flashback Friday: Nvidia Is the Ultimate Chip and Dip

Dow Ends Higher on Dovish Trump Tariff Comments; Nasdaq Falls

Dow Ends Higher on Dovish Trump Tariff Comments; Nasdaq Falls