If you are an alien (not a U.S. citizen), you are considered a nonresident alien unless you meet one of two tests. You are a resident alien of the United States for tax purposes if you meet either the green card test or the substantial presence test for the calendar year (January 1-December 31).

Certain rules exist for determining the Residency Starting and Ending Dates for aliens.

In some cases aliens are allowed to make elections which override the green card test and the substantial presence test, as follows:

You can be both a nonresident alien and a resident alien during the same tax year. This usually occurs in the year you arrive or depart from the United States. If so, you may elect to be treated as a Dual Status Alien for this taxable year and a Resident Alien for the next taxable year if you meet certain tests. (Refer to section "Dual-Status Aliens" – "First Year Choice" in Publication 519, U.S. Tax Guide for Aliens.)

A resident alien who is required to establish his/her U.S. residency for the purpose of claiming a tax treaty benefit with a foreign country should refer to Certification of U.S. Residency for Tax Treaty Purposes.