A good place to check out what you can deduct before you borrow is the chart on page 3 of IRS Publication 936. It’ll walk you through the requirements you must meet to deduct all of your home loan interest. It’s an hour well spent.

The first hurdle you’ll run into is the total amount of your loan or loans. In general, individuals and couples filing jointly can deduct the interest on up to $1 million ($500,000 if you’re married and filing separately) in combined home loans, as long as the money was used for acquisition costs, that is the cost to buy, build, or substantially improve a home, explains Scott O’Sullivan, a certified public accountant with Margolin, Winer & Evens in Garden City, N.Y. Any interest paid on loan amounts above the $1 million threshold isn’t deductible.

The same $1 million limit applies whether you have one home or two. Buying a vacation home doesn’t double your loan limits. And two homes is the max; you can’t deduct a mortgage for a third home. If you have a mortgage you took out before Oct. 13, 1987, you have fewer restrictions on claiming a full deduction. The calculations for “grandfathered debt” can get complex, so get help from a tax professional or refer to IRS Publication 936.

Whatever you do, don’t forget that you can also deduct the points and fees associated with a first or second mortgage when you initially buy your home, says Jeff Rattiner, a CPA with JR Financial Group in Centennial, Colo. If you refinance the same house, you have to deduct those costs over the entire term of the loan. If you refinance again, you can deduct all the costs from the earlier refi in the year you take out the new loan.

Spend loan proceeds wisely

The other limitation on how much you can borrow and still get your deduction comes into play when you take out a home equity loan or HELOC that you don’t use to buy, build, or improve your home. In that case, you can deduct the interest you pay only on the first $100,000 ($50,000 if married filing separately). This loan limit also applies in a so-called cash-out refi, in which you refinance and take out part of the equity you’ve built up as cash, says John R. Lieberman, a CPA with Perelson Weiner in New York City.

That means if you decide to take out a $115,000 home equity loan to buy that Porsche, you can deduct the interest on the first $100,000 but not on the $15,000 that exceeds the limit. Use the same $115,000 to add a new bedroom, however, and the full amount is allowable under the $1 million cap. Keep in mind, though, that the $115,000 gets added into the pot of whatever else you owe on your other home loans. In many cases, points and loan origination costs for HELOCs are deductible.

Consider this simplified scenario: You borrow $250,000 against your home at 8% interest. That means you’ll pay $20,000 in interest the first year. Spend the $250,000 on home improvements, and all of the interest is deductible. Spend $150,000 on improvements and $100,000 on your kids’ college tuition, and all the interest is still deductible.

But spend $100,000 on improvements and $150,000 on tuition, and the improvement outlays are deductible, though $50,000 of the tuition expense isn’t. That’ll cost you $4,000 in interest deductions. Preserve the $4,000 deduction by coming up with the extra money for tuition from another source, perhaps a low-interest student loan or by borrowing from a retirement plan. For someone in a 25% bracket, a $4,000 deduction lowers taxes by $1,000, plus applicable state income taxes.

Even if you’ve followed all the loan limit rules, you can still get stuck paying tax on mortgage interest. How come? It’s all thanks to the Alternative Minimum Tax. Congress created the AMT, which limits or eliminates many deductions, as a way to keep the wealthy from dodging their fair share of taxes.

Calculating the AMT can be complex, but if you make more than $75,000 and have several kids or other deductions, you might well be subject to it. Problem is, if you fall into the AMT group, you may not be able to deduct interest on a home equity loan, even if the loan falls within the $1 million/$100,000 limit. If you’re subject to the AMT and borrow money against the value of your home, you’ll have to use it to buy, build, or improve your place, or you may not have a chance to deduct the interest, says Rattiner, the Colorado CPA.

This article provides general information about tax laws and consequences, but shouldn’t be relied upon as tax or legal advice applicable to particular transactions or circumstances. Consult a tax professional for such advice.