I've been a Fool writer for more than a decade now, singing the praises of stock investing as the best way to amass long-term wealth, so I'll admit I'm a bit biased in favor of the stock market. But every now and then, I'll run into someone who's just as excited about real estate.

It can be hard to argue with someone who's realized significant gains on a smart real estate purchase. Some people bought homes for $12,000 that are now worth $300,000 or more.

The possibility of such a profit is enough to lure lots of folks who rightly want to build their nest eggs. But these people should be careful, because real estate isn't a slam-dunk investment -- it can go sour, too. And even if the price of real estate keeps rising, it still hasn't grown as fast as stock values, historically speaking.

Sure, that wasn't the case during the housing bubble. As measured by the S&P/Case-Shiller U.S. Home Price index versus the S&P 500, housing trounced stocks between 2001 and 2006, averaging 12.4% vs. 4.3% yearly.

But that's a short period. A study by Roger Ibbotson and Jack Clark Francis found that between 1978 and 2004, residential real estate offered a solid 8.6% annualized return, while the S&P 500 averaged 13.4%. Meanwhile, Yale's Robert Schiller looked all the way back to 1890 and found that real estate just barely kept up with inflation over the subsequent century.

The folks at Zillow.com have even worse news. According to the site, a quarter of all homes sold nationwide fell in price from what the sellers paid for them. As you'd expect, the likelihood of such losses is higher in previously hot areas like California.

So go into real estate with your eyes open. It can truly be an excellent investment, but it's not risk-free. For a safer, more diversified approach to real estate investing, consider real-estate-focused mutual funds like CGM Realty (FUND:CGMRX), which has averaged 22% over the past decade. Its top holdings recently included General Growth Properties (NYSE:GGP), Mosaic (NYSE:MOS), and Annaly Capital Management (NYSE:NLY).

If you'd like to find top-notch funds for your portfolio, take a free trial to our Motley Fool Champion Funds newsletter service. It's helped me find a bunch of winners for my own holdings.

Longtime Fool contributor Selena Maranjian owns shares of CGM Realty. CGM Realty is a Motley Fool Champion Funds pick. Annaly Capital Management is a Motley Fool Income Investor recommendation. The Motley Fool is Fools writing for Fools.