Walgreens Boots Alliance on Thursday beat fiscal third-quarter earnings estimates as higher prescription drug sales helped the company regain its footing after CEO Stefano Pessina dubbed last quarter "the most difficult" since the company was formed.

Walgreens reported adjusted earnings of $1.47 per share, beating analysts polled by Refinitiv's expectations of $1.43 per share. The drugstore chain posted $34.59 billion in sales. Analysts had expected $34.46 billion.

Shares of the company rose 4%. They've slid 21% this year.

Here's what the company reported compared with what Wall Street was expecting, based on a survey of analysts by Refinitiv:

Adjusted earnings per share: $1.47, vs. $1.43 expected

Revenue: $34.59 billion vs. $34.46 billion expected

"After what was a very disappointing second quarter for us, it is pleasing that to be able to report that this quarter has been brought in line with our expectations," Pessina said Thursday on a call with analysts. "That said, the pressures we have seen for some time continues to impact our businesses, and we still have a lot to do to develop the transformation and data to get ahead of the market trends again and return our company to strong and consistent growth."

Walgreens reported fiscal third-quarter net income of $1.03 billion, or $1.13 per share, down 12.1% from the $1.34 billion, or $1.35 per share, the company reported a year earlier. On an adjusted basis, Walgreens earned $1.47 per share, above the $1.43 per share analysts expected.

Chief Financial Officer James Kehoe told analysts the decrease in profit was mostly due to lower pharmacy margins, weakness in the U.K. drugstore business and declines in front-store sales in the U.S. Insurers, under pressure to lower prescription drug costs, are paying pharmacies less to fill prescriptions.

Amid ongoing challenges in the U.K. business, Walgreens will close about 200 Boots drugstores in the U.K., Kehoe said. The company is also reviewing its U.S. real estate footprint, he added.

"More to follow in the coming months as we work through these key opportunities," he said.

Sales in the quarter, which ended May 31, increased 0.7% from a year earlier, or 2.9% after accounting for fluctuations in currency rates. Walgreens attributed the increase to growth in its U.S. retail pharmacy business and pharmaceutical wholesale business. Sales in its U.S. drugstores open for at least a year fell 1.1% from a year earlier, which Walgreens attributed to its "de-emphasis" of tobacco products.

Walgreens maintained its full-year forecast of earnings to be roughly flat. The company cut its outlook last quarter from the previously guided 7% to 12% growth.

Walgreens and its competitors are under pressure, with insurers paying pharmacies less to fill prescriptions and consumers buying fewer household items at drugstores and more online. Facing these challenges, Pessina dubbed last quarter the "most difficult" since Walgreens acquired European drugstore chain Alliance Boots in late 2014 to form Walgreens Boots Alliance.

In its latest report, Walgreens said rising prescription drug prices led the 4.3% increase in U.S. pharmacy sales.

Walgreens has signed more than a dozen partnerships, with companies like Sprint, FedEx, Kroger and LabCorp, mainly aimed at driving more traffic into its stores. While these deals could help Walgreens test new store formats, analysts are skeptical they will drive meaningful revenue growth.