|http://www.irs.gov/pub/irs-pdf/p515.pdf (Pages 7 and 8.)
A resident alien is an individual who is not a citizen or national of the United States and who meets either the green card test or the substantial presence test for the calendar year.
Green card test. An alien is a resident alien if the individual was a lawful permanent resident of the United States at any time during the calendar year. This is known as the green card test because these aliens hold immigrant visas (also known as green cards).
Substantial presence test. An alien is considered a resident alien if the individual meets the substantial presence test for the calendar year. Under this test, the individual must be physically present in the United States on at least:
In most cases, the days the alien is in the United States as a teacher, student, or trainee on an “F,” “J,” “M,” or “Q” visa are not counted. This exception is for a limited period of time.
For more information on resident and non-resident status, the tests for residence, and the exceptions to them, see Publication 519.