The S&P 500 has been in rally mode for much of the past couple of years, and while that may make you feel great about the stocks you already own, it has gotten harder to find new bargains to buy. The average stock in the S&P 500 has seen its price-to-earnings ratio increase from around 20 times a year ago to more than 24.5 times now.

However, if you zoom in on the right corners of the market, you can still find some compelling long-term investment opportunities. For example, Prologis (PLD -1.54%) and Mid-America Apartment Communities (MAA -0.95%) are both down by about 30% from their peak price levels of three years ago -- a decline that can be traced largely to the impact that higher interest rates have had on commercial real estate values. With rates starting to fall again, these real estate investment trusts (REITs) should rise. In the meantime, investors can buy them at discounted prices and lock in compelling dividend yields. Given their strong businesses and balance sheets, they could supply investors with a lifetime of passive income.

A rapidly growing REIT

Prologis' stock has been under pressure in recent years even though demand for industrial real estate has remained robust. While demand has slackened a bit due to the impact of higher interest rates, this leading industrial REIT has still grown its core funds from operations (FFO) per share at a 13% compound annual rate over the last three years. That was faster than the REIT sector's 10% average growth. However, it was slower than the S&P 500's 18% compound annual growth rate.

The REIT's rapidly rising earnings have allowed it to continue increasing its dividend at a brisk 14% compound annual growth rate over the last three years compared to 7% for the S&P 500 and 9% for the REIT sector. That brought its streak of annual payout hikes to 11 years, with annualized dividend growth of more than 11% over the past decade.

With its FFO and dividends rising rapidly and its stock price down sharply, Prologis trades at a compelling level these days. Its dividend yield is over 3% (more than twice the S&P 500's average). Meanwhile, it trades at a discount to the S&P 500 at 22.5 times earnings. That's an attractive valuation for a company that should grow its earnings and dividend at double-digit percentages in the coming years as it capitalizes on the rising demand for logistics real estate.

Fading headwinds should reinvigorate growth

Mid-America Apartment Communities has faced some stiffer growth headwinds in recent years. The rock-bottom interest rates that prevailed in 2020 and 2021 fueled an apartment-building boom across the Sun Belt region where the REIT operates. That weighed on its ability to raise rents, slowing its FFO growth rate.

However, demand for apartments has remained strong, thanks to high employment and housing affordability issues. Because of that, its markets are steadily absorbing the new apartment supply. Meanwhile, with interest rates higher in recent years, the rate at which new apartment supply becomes available will start to slide in the second half of this year and into 2025. That should drive a resurgence in rent growth.

Despite the headwinds it has faced recently, Mid-America Apartment Communities has continued to increase its dividend. It gave investors a 5% raise late in 2023, extending its payment-hiking streak to 14 straight years.

That streak should continue. In addition to benefiting from a resumption of rent growth, Mid-American Apartment Communities has used its strong financial profile to capitalize on new investment opportunities. It currently has seven apartment developments under construction that it expects to complete before the end of 2026. Meanwhile, it plans to start four to six more over the next two years. On top of that, it recently acquired a newly built apartment community, and has the financial strength to buy more as opportunities arise.

Mid-America Apartment Communities currently trades at a compelling level of about 19.5 times its adjusted FFO, and at current share prices, its dividend yields nearly 4%. With its growth primed to reaccelerate, the REIT looks like an attractive long-term investment opportunity right now.

These great dividend stocks are still on sale

Prologis and Mid-America Apartment Communities have done a magnificent job growing their dividends over the years despite some recent headwinds. With those headwinds starting to fade, they look like terrific buys right now. They offer higher dividend yields thanks to their lower valuations. Add in their upside potential as rates fall and market conditions improve, and these REITs could produce healthy total returns over the long run.