There's an old saying that "politics makes strange bedfellows." We could add that business sometimes does too.

Pharmaceutical giant Eli Lilly (LLY 1.19%) and e-commerce/cloud services leader Amazon (AMZN 3.43%) might not seem to have much in common. However, the two companies will work together going forward in an important way. And both Lilly and Amazon stocks could benefit from the partnership.

How Lilly and Amazon are teaming up

Lilly announced on Wednesday that it will use Amazon Pharmacy to fill prescriptions for several of its drugs on its direct sales website, LillyDirect. The big drugmaker launched LillyDirect earlier this year.

Patients who use LillyDirect don't have to go to a doctor's office. Instead, Lilly's website connects them to an independent telehealth provider or helps them find a nearby healthcare professional if they prefer an in-person visit. LillyDirect also allows online pharmacies to obtain obesity, migraine, and diabetes prescription medications directly from Lilly and send them to patients' homes.

Amazon entered the online pharmacy business in November 2020. Amazon Prime members can receive free deliveries within two days for many prescription drugs. Customers who don't subscribe to Amazon Prime receive free shipping within four to five days. They can also upgrade to two-day shipping for a small fee.

Why this partnership makes sense

LillyDirect already works with Truepill to fill its online prescriptions. Amazon Pharmacy is the second online pharmacy to join forces with Lilly. The partnership makes sense for both big companies.

Lilly gains another alternative for filling patient prescriptions on LillyDirect. Bringing Amazon Pharmacy on board could attract more patients to LillyDirect. Amazon is exploring ways to deliver prescription drugs even more quickly than in two days. Lilly could benefit from those efforts.

Amazon Pharmacy will now deliver several of the most popular prescription medications on the market. The demand continues to skyrocket for Lilly's weight-loss drug Zepbound. Amazon Pharmacy will also deliver Lilly's migraine drug Emgality and diabetes products including Basaglar, Humalog, and Humulin.

The partnership with Lilly -- the biggest drugmaker in the world based on market cap -- could pave the way for Amazon Pharmacy to work directly with others in the industry. Amazon Pharmacy vice president John Love told CNBC that his company's rapid delivery "makes us an attractive partner and collaborator for all sorts of folks like Lilly, payers, providers, who are looking for a different type of pharmacy."

Why both Lilly and Amazon stocks should win

Lilly and Amazon saw their share prices rise slightly on the day their deal was announced, while the S&P 500 slipped a little. It's uncertain whether or not the news provided a small catalyst. However, both stocks should benefit over the long term as a result of the partnership.

LillyDirect could expand the market for Lilly's prescription drugs. Working with Amazon Pharmacy should increase the number of patients using LillyDirect. Meanwhile, Amazon has made a big bet with its move into healthcare. Lilly's selection of Amazon Pharmacy is another key step that should help that bet pay off. Of course, Lilly and Amazon stocks were big winners before the companies teamed up and would have likely continued to deliver exceptional gains even without their partnership.

Zepbound isn't Lilly's only big growth driver. Sales for the company's type 2 diabetes drugs Mounjaro and Jardiance and cancer drugs Verzenio and Tyvyt are soaring. Lilly hopes to soon win U.S. regulatory approval for Alzheimer's disease drug donanemab, which could become another blockbuster in its lineup.

Amazon's cloud services platform will almost certainly continue to enjoy a strong tailwind from the adoption of artificial intelligence (AI). The company has also made solid progress in boosting its profitability and free cash flow.