The S&P 500 (^GSPC 0.38%), the stock market's most widely followed index, has delivered slightly better than average returns over the past 12 months, rising by around 12%. However, the market's rocky start to 2025 has its year-to-date gains at just over 2% (as of June 9).

Although some may have predicted the S&P 500's slowdown, I imagine that not many people would have guessed that AT&T (T -0.34%), a stock that has struggled for the better part of the past decade, would gain 55% in the past 12 months -- more than four times as much as the S&P 500.

Yet even after that impressive run, AT&T stock still appears to be a solid long-term investment to buy now.

Woman uses a smartphone.

Image source: Getty Images

One of the best dividend stocks in the S&P 500

There's no doubt that AT&T's dividend is what attracts most of its shareholders. Even after its stock price bounce, its dividend still yields 4%, making it one of the more attractive income stocks in the S&P 500.

AT&T cut its payout by nearly half in 2022, and it has remained at $0.2775 per share quarterly ($1.10 annually) ever since. I don't think a dividend increase will be coming soon, but investors can feel confident in AT&T's ability to maintain its payout.

In the first quarter, AT&T's free cash flow was $3.1 billion, and it paid $2.1 billion in dividends. Management expects the company's free cash flow for the year to be at least $16 billion, with around $8.4 billion paid in dividends. Assuming that proves accurate, the telecom giant will have enough financial flexibility to maintain its dividend, pay down its debt, and make the necessary investments to stay competitive.

T Dividend Yield Chart

T Dividend Yield data by YCharts.

AT&T is leading the 5G and fiber race

AT&T's struggles stemmed in part from its ambitious effort to become a media and entertainment powerhouse -- a pursuit that drained resources, hurt its financial health, and ultimately failed to pay off. After parting ways with its media holdings in a $43 billion spinoff, AT&T has refocused its resources back to its core telecom businesses.

AT&T has been rapidly expanding its 5G and fiber businesses in hopes of creating sustainable growth and establishing itself as the leader of the next wave of network technology. It's not afraid of spending to do so, either. In 2024, AT&T made capital investments of $22.1 billion, and it plans to spend a similar amount in 2025. According to AT&T, it has been "the largest capital investor in U.S. connectivity infrastructure since 2019."

Those investments seem to be paying off. Its postpaid phone base continues to grow, and its fiber business has had 21 consecutive quarters with at least 200,000 net adds. The postpaid phone business doesn't grow fast, but fiber is a high-margin business once the infrastructure is in place. Once this happens, it should fuel AT&T's growth in the years to come.

The telecom industry is here to stay

One major advantage AT&T has is that it's a top player in a telecom industry that is as essential to daily life as food and water. (That's a bit dramatic, but you get the point.)

It also helps that AT&T operates in what is essentially an oligopoly with only two formidable competitors -- Verizon and T-Mobile. Of course, there are other telecom companies in the U.S., but the trio of leaders have achieved scales that make it challenging for new companies to compete. Factor in the high barriers to entry, such as infrastructure costs and regulations, and that already tough task becomes even more challenging.

AT&T's stock might not be flashy (despite its steep run-up over the past 12 months), but it could be a staple in your portfolio if you're looking to add a dividend stock.