“We’d like to start prepaying our mortgage, but we can’t do that and invest for retirement. Which should have the priority?”

That’s a common question — and there’s no one-size-fits-all answer. Your age, tax bracket, how long you expect to live in the house, your general attitude toward being debt-free, and what you do with tax savings related to paying mortgage interest all play significant roles.

Let’s say that two SMI readers are wrestling with this question. Rob is leery about the long-term health of Social Security, so he wants to start building his retirement funds immediately. For Mort, being in debt is more of a concern, so he plans to use any monthly surplus for additional principal payments on his home mortgage.

For comparison purposes, let’s make their two hypothetical situations identical: Both Rob and Mort have new $140,000, 15-year, 4% fixed-rate mortgages; both can set aside $1,200 out of each month’s paycheck (the mortgage payment is actually $1,036, leaving them each an extra $164 for payment of the principal or investment in a retirement account); both are in a 31% tax bracket (federal plus state), and both have an opportunity to contribute to a retirement plan at work that will earn a steady 6% (remember, this is hypothetical), which is 2% more than their mortgages are costing them.

When they make their first month’s mortgage payment of $1,036, $467 of that money is tax deductible as interest expense. Assuming they both itemize their deductions, this will lower each of their taxes by $145 a month (31% of $467). Key point: What they do with that $145 savings will make a big difference.

Both Rob and Mort would like to get their hands on that savings sooner rather than later. They’d get it back when they filed their income tax returns anyway, but why wait? So they both change the withholding instructions they give their employers so that about $145 less is withheld for income taxes each month.

By adding that amount to their monthly surplus of $164, Rob and Mort now each have an extra $309 to work with. Rob — the one focused on retirement — contributes his $309 into his company’s 401(k) plan. Mort — the one concerned about debt — takes his $309 and makes an extra principal payment on his mortgage.

Now here’s where it can get confusing. To construct an accurate picture, we have to recognize that Rob gets a second tax deduction — this time for putting money into his retirement plan. Rob’s $309 contribution is worth another $96 tax savings, which he could then also put into his 401(k). But then that $96 contribution would save him an additional $30 in taxes, which he could also put into his 401(k). But then that $30 . . . well, you get the idea. If Rob took maximum advantage of this, he could ultimately put $448 into his company retirement plan that first month — his $164 monthly surplus plus the tax savings of $145 for mortgage interest plus another $139 in tax savings generated by contributing to the company 401(k).

Assume that both men take the maximum advantage of the available tax savings as the years pass. Mort pays down as much extra on his mortgage each month as he can and in a little over 11 years, his mortgage is completely paid off! At that point, he shifts all the income that he would have formerly put toward his monthly mortgage payments into his retirement plan. Like Rob before him, he also adjusts his withholdings to take maximum advantage of the tax savings his retirement contributions create.

At the end of 15 years, the experiences of Rob and Mort can be summarized this way. Both men had the same out-of-pocket expenditures — $1,200 per month over 15 years, totaling $216,000. In return, they both accomplished paying their $140,000 mortgage loans in full and were able to invest for retirement. It’s interesting to note that, although they proceeded according to different timetables, Rob and Mort ultimately saved an equal amount ($34,144) on their taxes. This was due to each of them always taking full advantage of the tax-deductibility of mortgage interest payments and their 401(k) contributions in the years they were made.

The important difference in their financial situations after 15 years is found in the value of their retirement accounts. Rob’s 401(k) grew to $107,945 and Mort’s to $85,780 — a difference of $22,165. Although they had both saved the same amount in taxes which could then be invested for retirement, Rob’s savings were “front-loaded.” That meant he could put them to work in his 401(k) earlier than Mort could. In this way, Rob was able to take greater advantage of the tax-deferred compounding of profits. Mort’s retirement account came on strong later, but Rob’s head start was too great. (The difference in his 401(k) would have been even greater if Rob’s employer contributed matching funds.)

Does this mean you should follow Rob’s example? Not necessarily. To make it work, you must aggressively use all of the tax savings available, which few people do. More importantly, achieving results similar to Rob’s would require 15 years of relative stability in your job, the economy, and the tax code. That seems like a lot to ask from the next decade or two!

Instead of choosing one goal or the other, splitting your surplus and working on both simultaneously is often a reasonable decision.