Rite Aid (RAD -16.67%) did its shareholders right on Thursday by delivering a far-better-than-expected third quarter of fiscal 2021.

The big pharmacy operator published the results of the quarter this morning, and they revealed a 12% year-over-year jump in revenue to $6.1 billion. More encouragingly, against expectations, Rite Aid landed in the black on the bottom line, even as its adjusted net profit fell by 26% to $21.6 million, or $0.40 per share.

A Rite Aid store at twilight.

Image source: Rite Aid.

On average, analysts following the stock had been estimating the company would book $5.8 billion in revenue, and an adjusted net loss of $0.05 per share.

A big reason for Rite Aid's positive surprise was the cornavirus pandemic. With worries about health foremost on many customers' minds, pharmacy sales rose by over 6%. By comparison, front-end (i.e., nonpharmacy) sales crept up only by 0.3%. Meanwhile, the company's pharmacy benefits manager Elixir saw its take increase by a very robust 29% to $2.1 billion for the quarter.

Buoyed by these results, Rite Aid slightly increased its guidance for the full 2021 fiscal year. The company now believes its total revenue will land between $23.9 billion and $24.2 billion, which at the low end would mean a year-over-year improvement of almost 9% (previous guidance: $23.5 billion to $24 billion). Per share adjusted net income should be $0.45 to $0.85, and free cash flow is estimated at $50 million to $100 million.

With a mass rollout of coronavirus vaccines in the cards, Rite Aid has good momentum going into 2021. Investors rewarded this by bidding the stock up by over 17% on Thursday, trouncing the modest gain of the S&P 500 index on the day.