U.S. immigration laws often refer to citizens of another country as "aliens," whether or not they are lawfully present in the United States. However, the terms "resident alien" and "non-resident alien" come from a different source entirely: they are actually terms from the federal tax laws. The main difference is that resident aliens owe tax on all their worldwide income, while non-resident aliens owe tax only on income generated from U.S. sources.
As you become better acquainted with these definitions, you'll realize that, contrary to popular myth, you don't need to have a green card in order to owe taxes to the U.S. government.
There are two tests for whether federal tax law classifies someone as a resident alien:
This applies to someone who has U.S. permanent or conditional residence, or a green card. The person is a citizen of another country who is authorized to live and work in the U.S. on a permanent basis (or, in the case of a conditional resident, for two years that might then be continued into a permanent stay).
By the very nature of the requirements placed upon U.S. permanent residents, they spend most of their time living in the United States. To keep your green card, you must not make your primary home in another country and "abandon" your residence, nor remain outside the U.S. for more than one year.
(People who plan to remain outside the United States for more than one year can, however, apply for a re-entry permit before leaving, in order to preserve their green card.)
Even without having a green card, a person who spends 31 days in the United States during the current year and 183 days during a three-year period that includes the current year and the two years immediately before that is considered a resident alien.
This affects many people who are in the U.S. on temporary, otherwise known as nonimmigrant visas.
There are various exemptions to this tax obligation, such as for time people spent in transit (less than 24 hours in the U.S.), time during which the person couldn't leave because of needing medical treatment, as well as teachers and students (on an F, J, M, or Q visa) who haven't stayed in the U.S. beyond a certain period of time.
If you are spending some time in the U.S., but do not meet (or are exempt from) either the green card or the substantial presence tests, then you are most likely a non-resident alien. Visiting students and teachers are often classified as non-resident aliens in the early years of their U.S. stay.
For more details on these definitions, see IRS Publication 519, U.S. Tax Guide for Aliens.
If you are a resident alien, your U.S. tax obligations are much the same as those of a U.S. citizen. You must report all your worldwide income to the IRS, even if you remain outside the United States for an entire year.
If you are a non-resident alien, your tax obligation to the U.S. government is reduced. You'll even use a different tax form than the regular Form 1040, and be taxed at different rates than resident aliens and citizens. You'll owe tax only on income that was generated within the U.S, not including any capital gains. And you might also be able to take advantage of some international treaty exemptions.