Despite disappointing quarterly earnings results, shares of Rite Aid surged 24% Thursday on news of a deal with Amazon that gave investors hope for a turnaround.

Rite Aid's stock had slid more than 8% in premarket trading before rebounding after the markets opened. The company announced a partnership with Amazon on Thursday, saying it would open Amazon pickup counters in 1,500 of Rite Aid's stores by the end of the year.

The company lost 99.3 million, or $1.88 a share during the fiscal first quarter that ended June 1. The loss was wider than expected, even after adjusting for restructuring costs and other expenses. Analysts polled by Refinitiv expected the company to lose 8 cents per share on an adjusted basis, not the 14 cents per share adjusted it reported.

Rite Aid also missed revenue estimates, posting $5.37 billion in the quarter, short of the $5.38 billion Wall Street anticipated.

Pressure to rein in prescription drug prices weighed on Rite Aid during the quarter, a problem that has also plagued rival pharmacy chains. Insurers are paying pharmacies less to fill prescriptions, eating away at pharmacies' profits.

Rite Aid executives said the company is already taking steps to improve its performance for the year and plans to design new payment models, such as getting paid for proving it can make patients healthier, so it doesn't need to rely on the traditional system that's clearly under pressure.

"These efforts are helping us identify significant opportunities to drive further growth and operating efficiency," CEO John Standley told analysts on a conference call. "While still early in the process, we expect these initiatives to drive significant value in fiscal 2021 and beyond while reducing our reliance on traditional pharmacy reimbursement rate models."

Rite Aid is trying to find its way forward after two failed attempts to sell itself over the past few years. It sold nearly 2,000 locations to Walgreens after plans to merge the two companies faltered. Rite Aid now operates 2,466 stores, making it a much smaller player than Walgreens and CVS Health, which each own about 10,000 drugstores.

For the full year, Rite Aid gave investors a wide projection, forecasting a loss of as much as 14 cents per share to a profit of as much as 72 cents per share. It previously forecast a loss of 1 cent to income of 4 cents per share. The company completed a reverse stock split earlier this year at a ratio of 1-for-20 in order to boost its share price and keep its stock from being delisted on the New York Stock Exchange.

Rite Aid reiterated its full-year sales forecast of $21.5 billion to $21.9 billion and comparable sales to increase up to 1%.