Shares of the Deerfield, Illinois-based company, which also maintained its forecast for full-year profit, rose nearly 5% to $54.84 in morning trading.
The earnings report helped soothe some of the investor worries after the company, plagued by low reimbursements, slashed its full-year adjusted earnings growth forecast in April from a range of 7% to 12% to roughly flat.
Walgreens, which replaced General Electric Co GE.N on the blue-chip Dow Jones Industrial Average last year, is the worst performing stock on the index, with year-to-date losses of 23.4% through Wednesday close.
"Many people are looking at our company ... focusing on the immediate risk that we have to face," Chief Executive Officer Stefano Pessina said. "And understand this, we're far from complacent about the pressures we face."
The company said it has been able to cushion reimbursement pressures from insurers in recent years through benefits it received in the process of procuring generic drugs.
However, as prices of generic drugs stabilize, Walgreens said its dependence on these benefits has reduced.
"Recognizing this, we are accelerating our other levers to mitigate the pressure," Pessina said on a conference call.
Walgreens said it was reviewing its retail footprint in the United States, and highlighted partnerships it had with other companies such as FedEx Corp and Kroger Co to offer a range of services at its pharmacies.
The performance in the company's UK Boots business, however, continued to lag.
Boots plans to close stores where it has several sites on the same shopping street, Seb James, managing director of the 170-year old Boots UK business, told Reuters on Wednesday.
Same-store sales at its U.S. pharmacies rose 6% in the third quarter as it filled 290.7 million prescriptions. Three analysts polled by Refinitiv had expected a 2.9% rise in same-store sales.
"While one quarter does not make a trend, it was good to see pharmacy sales in the U.S. outperform our expectations, despite ongoing reimbursement challenges," Edward Jones analyst John Boylan said.
Excluding items, the company earned $1.47 per share in the third quarter ended May 31, beating analysts' expectations of $1.43 per share, according to IBES data from Refinitiv.
(Reporting by Aakash Jagadeesh Babu and Manas Mishra in Bengaluru; Editing by Maju Samuel)
By Manas Mishra and Aakash B