Q: My husband and I have a rental income property and live in our primary residence. I would like to sell both and move to another state.

We’ve lived in the primary residence for about 11 years and bought the rental about 5 years ago. We refinanced both of the mortgages several times over the past couple of years. How would this affect us with the capital gains tax? Is there anything we can do to lower our taxes on the sale of these properties?

A: If you sell both properties now, you’ll get to shelter up to $500,000 (if you’re married, $250,000 if you’re single) in profits from the sale of your primary residence, but you will have to pay capital gains tax on the profits from your rental property.

But you have other options. You can sell your primary property and move into your rental for two years. At the end of two years, you can sell the rental (which has since become your primary residence) and shelter another $500,000 in profits tax free. In the meantime, you can use the profits from the sale of your original property and purchase another property in the state in which you intend to move. When you sell the rental, you can make the big move to the other state.

Here’s another option: You can sell your primary residence and shelter the profits, and use the cash to buy another primary residence in your new state. You can sell the rental and do a 1031 tax-free exchange. That allows you to defer taxes on the profits generated by the sale of the rental as long as you buy a similar property elsewhere that costs at least as much as the one you are selling.

If you like having a rental, this might be a way to have your cake and avoid paying tax on it.

Here’s how your refinancings will affect your taxes: When you sell your home, any unused points that were amortized over the life of the loan can be deducted in the year you sell.

Talk to your accountant for more details. If you decide to do a 1031 tax-free exchange, consult with a real estate attorney who has plenty of experience closing these transactions.