The U.S. drugstore chain Walgreen Co. has agreed to buy a 45 percent stake in Alliance Boots, the European pharmacy retailer, for $6.7 billion, in a deal that will allow both companies to extend their global reach.

Walgreen, which could gain full control of the company by 2015, can take advantage of Alliance Boots’ operations across Europe and in several emerging markets.

The deal will create one of the world’s largest drugstore and pharmacy retailers, with more than 11,000 stores in 12 countries, as well as a wholesale pharmaceutical business with operations in 21 countries.