A drawn-out acquisition bid dented Walgreens’ fourth-quarter profit, but the nation’s largest drugstore chain topped expectations and it introduced a 2018 forecast that exceeds analyst predictions.

Walgreens blamed termination fees and costs related to its pursuit of rival Rite Aid Corp. for a 22-percent drop in fiscal fourth quarter earnings, which fell to $802 million from $1.03 billion.

The company first announced a plan to buy Rite Aid in 2015, but regulators were reluctant to embrace a combination of the nation’s largest and third-largest drugstore chains, and the $9.4 billion bid languished for more than a year before Walgreens ended it in June. The company agreed to pay a $325 million termination fee to Rite Aid and another $25 million to Fred’s Pharmacy after it also ended a related deal.

Walgreens then announced a slimmer Rite Aid deal last month. The company is now spending $4.38 billion on about 1,900 Rite Aid Corp. stores, some distribution centers and inventory.

The company said Wednesday it has already acquired its first Rite Aid stores, and it expects to complete all the store transfers by next spring. Walgreens currently has more than 13,200 stores worldwide.

As part of that deal, the drugstore chain plans to close about 600 locations. A company spokesman said most of the closings will involve Rite Aid locations, and the vast majority will be within a mile of another store in the Walgreens network.

He declined to say where the closings would occur. They will start next spring.

In the fourth quarter, Walgreens reported adjusted earnings of $1.31 per share, as sales climbed more than 5 percent to $30.15 billion.

Analysts expected earnings of $1.22 per share on $30.05 billion in revenue, according to Zacks Investment Research.

Sales at stores open at least a year climbed 3 percent. That’s a key metric for gauging a retailer’s health because it excludes recently opened or closed stores.

For the year, the company reported profit of $4.08 billion, on $118.21 billion in revenue.

In 2018, the company expects adjusted earnings per share to range between $5.40 and $5.70.

Analysts forecast, on average, $5.45 per share, according to FactSet.

Shares of Deerfield, Illinois-based Walgreens Boots Alliance, Inc. slipped 12 cents to $67.17 in midday trading, while broader indexes also fell.

The stock had dropped 19 percent since the beginning of the year.

_____

Elements of this story were generated by Automated Insights (http://automatedinsights.com/ap) using data from Zacks Investment Research. Access a Zacks stock report on WBA at https://www.zacks.com/ap/WBA