Some divorcing homeowners end up with unanticipated tax bills when they sell their home. Find out how you can avoid being one of them.

The federal tax law signed by President Donald Trump Dec. 22, 2017, may affect home ownership tax benefits described in this article. The new law goes into effect for the 2018 tax year and generally doesn’t affect tax filings for the 2017 tax year. Here’s a detailed summary of the changes.

If you’re getting divorced, your home may be the biggest asset you’ll have to divide with your soon-to-be ex. As you decide whether to sell it and split the proceeds or let one spouse live there until the last kid launches, remember there’s often a third party involved in your home sale transaction: Uncle Sam.

Keeping, selling, or continuing to share your home can each create different federal tax tabs for you and your ex-spouse. Here’s a look at the tax consequences for six of the most common situations divorcing couples face.

1. One of You Stays in the House Until the Kids Grow Up; Then You Sell It

If you’re the one who moves out and agrees to hold off on selling the house until the kids are grown, you can end up with a whopping tax bill years later. That’s because the tax law provision that lets you avoid tax on home sale profits (or in tax speak, capital gains) typically only applies if you’ve lived in the house for two of the past five years.

Unless the kids are older and will be out of the house soon, the spouse who moves out typically won’t meet that two-year test.

Luckily, there’s a way to avoid this problem: If the divorcing spouses can agree that one of them will be granted use of the property under a divorce or separation instrument, the spouse who leaves can still consider the property as his or her main home under tax rules as long as the former spouse is living there. (You’ll need the supporting documentation — the decree — to prove this with the IRS, especially if you maintain this arrangement for more than 6 years.)

When the house is finally sold, each former spouse can avoid paying tax on up to $250,000 of profit from the sale. This is the same beneficial tax treatment they would have received had the divorce never happened.

Avoid Costly Financial Mistakes

2. One of You Buys Out the Other’s Share of the House Now

When you want to keep the house but lose the spouse, a buyout can work for both of you. In a buyout, you buy your spouse’s share of the house.

You don’t have to pay exactly half the value of the house; it can be any amount that works for you both given other assets you’re dividing. To decide the current value of your home, ask a REALTOR® to do a broker’s price opinion for you.

Typically, the spouse who stays refinances the current mortgage, but that doesn’t have to happen.

Generally, you don’t have to pay taxes on any gain or loss you have from the buyout. That’s true even if the house is just one part of the bigger plan to divvy up your assets and debts — for example, if you get the house because you agreed to give your ex-spouse cash or to pay off debt you both owe.

Warning for spouses who are moving out: Be sure the mortgage really was paid off. Otherwise, you could still be liable for paying it. Call or write your lender and ask it to send a copy of the mortgage lien release to your new address. That’ll come in handy in the unlikely event that the mortgage continues to show up on your credit report and you need to prove it was paid off.

3. You Sell and Both Move Out

Some couples opt for a clean break from each other and from the home they shared. They sell the home and split the profit based on their divorce agreement.

If you sell a home you own jointly with your spouse, each of you can typically exclude up to $250,000 in home sale profits if you’re filing as a single and $500,000 if you’re filing a joint return. IRS Publication 523, Selling Your Home has the details.

The IRS fine print on the exclusion requires that:

The home was your main (principal) residence.

You lived there for two of the past five years.

You only use the exclusion once every two years.

Spouses who haven’t lived there for two of the past five years (perhaps because of job transfer or military deployment) might be eligible for a partial exclusion of the gain. You’ll find more information on those in Publication 523.

4. You Continue to Share the House

Some couples who share custody of their children want to avoid having the kids shuffle between the parents’ two homes. The kids stay in the original house and the parents take turns living with kids some weeks and living in a second home or a rental during the other weeks.

The tax repercussions depend on whether you still consider the main home to be your principal residence. If, for example, you still get your mail there and keep it as your address for your driver’s license, it would likely still be counted as your home for tax purposes.

5. You Have a Vacation or Second Home to Divide

You don’t get that lovely home sale profit (capital gains) exclusion when you sell a vacation home, so you’ll likely owe tax if you make money from selling a vacation home due to a divorce.

Capital gains tax varies based on your income. Most people pay 15% in capital gains taxes on their vacation home sale profits. Low-income sellers might pay no capital gains taxes, while those with a taxable income above $406,750 would pay 23.8%, including the 3.8% surtax on net investment income.

If you don’t sell and instead get your spouse’s share of your vacation home, you won’t have to pay taxes on the transfer as long as it’s part of your original or modified divorce or separation agreement.

Maybe you can continue to share your vacation home with your ex-spouse and work out a written usage agreement as part of your divorce. You could each use the home 26 weeks of the year, for example.

6. You Own Rental Properties

In general, if you give or receive a rental property as part of your divorce agreement, you won’t owe income taxes because of that transfer. But the spouse who sells the property in the future might owe tax on the recaptured depreciation that you both took in the past.

Depreciation is an annual allowance real estate investors get for the wear and tear, deterioration, or obsolescence of a property. When investors sell a property, they owe taxes on the depreciation they deducted in prior years.

Ask your accountant how the depreciation you both claimed might be recaptured and whether there are ways to avoid paying tax on recaptured depreciation.

Three Caveats

There are three important exceptions to the six situations for divorcing homeowners outlined above:

They don’t apply if your spouse is a nonresident alien.

Properties held in trust follow a different set of tax rules outlined in Publication 504.

Property you got in a divorce agreement that happened before July 19, 1984, falls under a different set of IRS rules outlined in Publication 504.

One-Off Property Situations for Divorcing Couples

Although most people will find themselves in one of the six situations discussed above, other home-related tax complications can arise from divorce, especially if you continue to have a joint mortgage on a home that only one of you continues to own and/or live in. Here’s how the taxes play out for some of these one-off situations:

You used the first-time homebuyer tax credit.

Whichever spouse keeps the house is responsible for potentially repaying the first-time homebuyer tax credit if relevant. File Form 5405 to let the IRS know you don’t own the house anymore because of your divorce.

You pay the mortgage but don’t own the house.

Sorry, you can’t deduct the mortgage interest unless you own the home.

You don’t own the home and your ex pays the mortgage.

Sorry, you can’t deduct the mortgage interest unless you own the home and pay the interest.

You own the home but your ex pays the mortgage.

You report the mortgage payment on your tax return as alimony income and you then get to deduct the mortgage interest payment on Schedule A of Form 1040 if you itemize. You have to be legally obligated to pay the mortgage to be able to take the mortgage interest deduction.

If your lender sends your spouse (instead of you) Form 1098 (the form that proves to the IRS that interest payments were made), put a statement in with your tax return telling the IRS:

You own the house

Who the 1098 went to

Where the 1098 got mailed

You both own the home and you both pay the mortgage.

If both spouses own the house and contribute to the mortgage payment, but only one of you lives in the house, you each deduct the mortgage interest you pay. To take the mortgage interest deduction, you have to own the home and be legally obligated to pay the mortgage. Each of you should include a statement with your respective returns, noting that you pay a share of the total interest shown on Form 1098.

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 tax advice and a legal professional for legal advice.

has been writing about real estate for more than two decades. She lives in a suburban Baltimore Midcentury modest home on a 3-acre lot shared with possums, raccoons, foxes, a herd of deer, and her blue-tick hound. Follow Dona on Google+.