Image source: Flickr user William Warby.

The U.S. tax system has gotten a lot of attention lately for how it treats U.S. corporations, forcing them to pay tax on their worldwide income rather than focusing solely on what they earn domestically. But what many people find surprising is that even foreign citizens living in the U.S. face similar treatment from the IRS, which extends its reach well beyond the nation's boundaries. Below, we'll look at how foreign citizens get taxed and what it means for you.

Resident aliens and U.S. tax
Most noncitizens who live in the U.S. are treated as what the IRS calls resident aliens. In order to qualify as a resident alien, you need to meet one of two conditions. Those who are lawful permanent residents of the U.S. because they have a green card are resident aliens. Alternatively, you can qualify by being physically present within the U.S. for at least 31 days out of the current year and for at least 183 days during a three-year period consisting of the current year and the two preceding years. However, for purposes of the 183-day test, only the days present during the current year get full weight. You only include one-third of the days in the previous year and one-sixth of the days in the year before that in calculating the total.

If you are a resident alien, then you generally get treated for tax purposes the same way as a U.S. citizen. You must report all income whether it's earned inside the U.S. or outside, and you can typically claim exemptions, deductions, and tax credits in the same way as U.S. citizens.

However, there can be some complications. For example, if only one spouse in a married couple is a resident alien and the other is a nonresident, then you can't file a joint tax return unless you make a special election to have the nonresident spouse treated as a resident alien. The trade-off is that the nonresident spouse has to include all worldwide income on the U.S. tax return just as the resident alien does. Similar issues can arise with respect to claiming dependents.

Tax on nonresident aliens
If you're a foreign citizen living in the U.S. but don't live here long enough to qualify as a resident alien, then you're treated as a nonresident alien. The rules covering nonresident aliens are much trickier and more closely resemble what tax systems in foreign countries do with corporate taxes.

In general, nonresident aliens do not have to report their worldwide income on their U.S. tax return. Instead, you'll report only the portion that's subject to U.S. tax. That includes two general categories: income that is effectively connected with a trade or business in the U.S., or U.S. source income that is fixed, determinable, annual, or periodical. Effectively connected income is made up of income from U.S. sources that are connected with the conduct of a trade or business, including the performance of personal services. Fixed, determinable, annual, or periodical income includes almost everything else, except for capital gains from the sale of real or personal property and items that are excluded from income such as municipal bond interest.

When income isn't effectively connected with a trade or business, a flat tax rate of 30% applies unless a tax treaty between the U.S. and the nonresident alien's home country calls for a lower rate. Deductions aren't allowed against this type of income. By contrast, income that is effectively connected gets taxed with the same graduated tax brackets that resident aliens and U.S. citizens pay.

Taxes are complicated enough even when you don't have citizenship issues to consider. If you're a foreign citizen living in the U.S., you need to run the numbers to determine whether you're a resident or nonresident alien. Once you've figured that out, you can see which rules you'll need to follow in order to prepare your taxes correctly.