The fortunes of many homebuilders over the past several years, including Ryland Group (NYSE:RYL), KB Home (NYSE:KBH), and Beazer Homes (NYSE:BZH), have hinged on the willingness of many homeowners, especially retirees, to buy second homes, often in a different state. But when thinking about your taxes, where you live can make a big difference. People who live in places without a state income tax, such as Florida and Texas, will likely want to avoid having to pay income tax in other states. At the very least, you'll want to be absolutely sure you won't have to pay taxes twice on the same income.

Residency and taxes
In general, a state can impose income taxes in two ways: on its residents, and on anyone who earns income from resources within the state, even if the owner of those resources is not a resident.

Say, for example, that you live in St. Louis but do business throughout the metropolitan area. Missouri will treat you as a resident because you live there, and it can therefore assert its right to tax all of your income. However, if you earn 25% of your income from doing business across the river in Illinois, then Illinois can impose an income tax on that 25%, even though you're not an Illinois resident.

As you can imagine, having to deal with multiple states and their income tax systems can be extremely complicated. Yet things can get even more complex when you live in two different states during different periods of the year -- as owners of multiple homes often do -- because it's not always clear which state has the right to treat you as its resident.

Dueling definitions of "resident"
The main problem for taxpayers living in two different states is that the rules governing whether a state will treat someone as a resident aren't always consistent with those of other states. As a result, you have to look closely at the tax laws of both states to figure out which one will claim you as a resident and therefore impose tax on your entire income.

Some states, especially those that face substantial resistance among taxpayers, impose fairly strict guidelines on whom they will treat as residents. For instance, New York must deal with a number of people who spend a good amount of time within the state but also maintain homes in Florida, which has no state income tax. To strengthen its grip over people whom it considers to be evading state income taxes, New York asserts its power to tax anyone who has a tax domicile in New York, spends at least 30 days in the state, and has a permanent home there.

In determining whether taxpayers have a New York tax domicile, the state looks at a number of factors, including where they work, whether they keep property in another state, where they get medical care, where they vote, where their cars are registered, and where their family lives. Another example exists in California, which must address taxpayers who go back and forth to tax-free Nevada and Washington. However, California has specific regulations that limit the ability of its state tax department to treat taxpayers as residents even if they own a home, have bank accounts, or belong to social clubs within California.

A break on double taxation
As long as you take care to avoid being considered a resident of multiple states, you usually won't have to deal with double taxation, even if you have to file more than one tax return. Most states allow residents to claim credits for income taxes they had to pay to other states. So in the example about the St. Louis resident, Missouri would give you the opportunity to claim a credit for any taxes you had to pay on your income from Illinois.

Furthermore, most of the income that retirees typically earn, including interest, dividends, and other regular investment income, is treated as being earned in the state in which they maintain their primary tax residence. Because the physical location of stocks, bonds, and other securities is difficult to define, coming up with an easily administered alternative system would be difficult. On the other hand, if you have other types of income, such as rental income on real property or capital gains from the sale of real property, you'll probably have to treat that as income from the state in which the real property is located, regardless of your residence.

Although the state tax credit can reduce the impact of taxation in multiple states, it may nevertheless result in your having to pay tax at a higher rate than you might otherwise have to. If you're willing to fit your way of life to the tax-residency rules, you can sometimes save a lot of money.

State taxes aren't as substantial as federal taxes, but especially for retirees on a limited income, they can still be worth avoiding. By knowing the particular rules affecting people who live in different states during the year, you can take advantage of the most favorable state's tax rules to the fullest extent possible.

Related articles:

It's never too early or too late to start planning your retirement. Start up a risk-free trial to Rule Your Retirement today, and get yourself started on the path to a secure and prosperous lifestyle during your golden years.

Fool contributor Dan Caplinger lived in two different states last year, but he's done just about everything he could to sever ties to his old home. He doesn't own shares of the companies mentioned in this article. The Fool's disclosure policy moves with you.