NEW YORK (MainStreet) -- Economic troubles in Europe, conflict with Iran and an uncertain presidential campaign season in the U.S. make the stock and bond markets look rather hazardous these days, so why not make a simple, guaranteed investment that can earn tens of thousands of dollars over the years, perhaps more? How do you do it? Simple. Just pay off your mortgage.

The mortgage payoff option has starkly divided camps of believers and critics. But as usual the truth is more nuanced. Assuming you have the cash on hand, the benefits of the payoff depend on both the homeowner’s circumstances and the prevailing market conditions.

A key condition of today’s market – extremely low mortgage rates – should give many homeowners pause when considering a payoff, as the amount saved in interest payments, which are historically low right now, might be eclipsed if that extra cash were invested elsewhere.

All else being equal, the payoff decision revolves around a comparison between the mortgage rate and the rate of return on an alternate investment. Pay off the final $100,000 on your 4% mortgage and you’ll save $4,000 in interest charges. If an investment in stocks would pay 7% (the historic average for investment in the stock market), that capital could earn $7,000, making the stock investment preferable.

Of course, the return on the mortgage payoff is guaranteed, while stocks are risky – if your stock tanks you could lose the entire amount you invested. That’s why many people prefer to compare the mortgage payoff to what could be made on an equally certain alternative like U.S. Treasury bonds. With the 30-year Treasury yielding just under 2%, the mortgage payoff would be twice as profitable.

Still, some homeowners may feel the risk of investing in the stock market is worth a shot. After all, market worries can create bargains.

“Mortgage interest rates seem to touch new lows every week, while equity valuations aren't outlandish by many measures, even after their three-year run-up,” writes Christine Benz, director of personal finance for Morningstar Inc., the market-data firm.

“Although out-earning one's mortgage interest rate might not have seemed realistic a decade ago, with 30-year mortgage rates higher than 7% and the market still working through post-dot-com-bubble valuations, doing so doesn't look so unreasonable today.”

Even some conservative experts forecast stock market returns exceeding 5% for the next seven years, she notes. (That’s 5% after inflation, or 7% if inflation averages 2%.)

An option to consider is to use part of your disposable capital to refinance the mortgage to today’s low rate, then invest the rest in stocks.

Homeowners in or near retirement might still do better with a mortgage payoff because their investment strategy generally leans toward the conservative anyway, Benz says. Also, people who have had their mortgages for many years save very little on the mortgage interest deduction, because the bulk of their payments go toward paying off principal, not interest. That makes keeping the mortgage less attractive.

A younger homeowner, however, might do better sticking with a low-rate mortgage and investing the spare cash elsewhere, Benz adds. These homeowners have more time to benefit from investment compounding, and to ride out market downturns.

“The case for investing in the market rather than prepaying the mortgage gets even stronger if you hold your investments within the confines of a tax-sheltered vehicle and/or you're earning matching dollars on your contributions,” Benz notes.

“On the flip side, portfolios that are heavy on cash and fixed-income securities, especially those that are fully taxable from year to year, are less likely to out-earn mortgage interest rates.”

Paying off a mortgage early makes sense only if the homeowners can afford to tie money up in the home, as the only way to get that cash out if you need liquidity down the road is to sell the home, refinance or take out a home equity loan.

Bottom line: The payoff decision is never made for good – it should be revisited from time to time as the homeowner’s situation and market conditions change.

If you’re more in the market for a refinancing deal than a prepayment arrangement, be sure to check out MainStreet’s look at 5 Common Refinancing Mistakes and How to Avoid Them!