Investing in pharmaceutical stocks can carry risks. It's not always clear which drugs will be successful and turn into blockbusters for their respective businesses. As a result, it can take years before investors see significant gains from these types of investments.

But one way you can stack the odds in your favor is by going with businesses that have significant pipelines and that also have excellent track records for growth and innovation. Two companies that easily check off both boxes are Eli Lilly (LLY -0.89%) and AstraZeneca (AZN -1.26%).

Here's why these can be solid pharma stocks to buy and hold not just for years, but decades.

A patient undergoing a checkup at a doctor's office.

Image source: Getty Images.

Eli Lilly

Eli Lilly is an example of a terrific healthcare stock that you can buy and hold for decades. With a rich history for innovation and a vast pipeline of drugs, the Indianapolis-based drugmaker has some excellent financials today, plus it has solid prospects for even more growth in the long run.

Today, the company's operations center around two highly popular injectable GLP-1 products -- Mounjaro (diabetes) and Zepbound (weight loss). They share the same active ingredient, tirzepatide, and there is tremendous potential for it to potentially help treat other diseases and conditions.

In a recent clinical trial, for example, tirzepatide has shown potential as a treatment for fatty liver disease. And data also suggests GLP-1 drugs can help curb addiction. In the short term, the company hopes to have a weight loss pill hitting the markets, possibly as early as next year.

What's encouraging is that the business is already generating fantastic results right now. This year, the company's guidance calls for revenue between $60 billion to $62 billion. That's an increase of about 36% from the $45 billion it generated last year. And it's nearly double the $34 billion it posted in 2023.

Eli Lilly is a growth machine and its continuous investments into expanding its pipeline, whether it's through in-house development or acquisitions, makes it an unstoppable growth stock to buy and hold for not only years, but decades. Although its valuation may appear high, as it's trading at a price-to-earnings (P/E) multiple of more than 50, that will be less of a concern in the long run as its bottom line is likely to grow significantly over the years.

AstraZeneca

Another big name in healthcare that's worth investing in for the long haul is U.K.-based AstraZeneca. Its pipeline is extensive with the company having close to 200 projects that it's currently working on. It has plenty of diversification as it focuses on multiple therapeutic areas, including oncology, respiratory and immunology, rare diseases, vaccines, immune therapies, cardiovascular, and others.

One exciting area that it is investing in is into radioconjugates, which are possible replacements for chemotherapy as they are more targeted treatments. A problem with chemotherapy is that healthy cells can get damaged in the process but radioconjugates aim to directly target cancer cells.

Last year, AstraZeneca acquired a clinical-stage company, Fusion Pharmaceuticals, to accelerate its drug development in this area. This is a long-term ambition but one that has tremendous potential if it proves to be successful, as it can revolutionize cancer treatments.

AstraZeneca has been investing heavily into its growth and it projects that by 2030, it will be generating around $80 billion in annual revenue. That would represent a 48% increase from the $54 billion in revenue that it reported last year.

The stock trades at a P/E multiple of 32 and is a cheaper option than Eli Lilly, but both can make for excellent pharma stocks to hang on to for decades given their robust growth opportunities.