Straight from the ATF website...
(A15) Q. May foreign visitors and other aliens legally in the United States purchase or possess firearms and ammunition while in the United States?
A. Nonimmigrant aliens generally are prohibited from possessing or receiving (purchasing) firearms and ammunition in the United States.
There are exceptions to this general prohibition. The exceptions are as follows:
nonimmigrant aliens who possess a valid hunting license or permit lawfully issued by a State in the United States;
nonimmigrant aliens entering the United States to participate in a competitive target shooting event or to display firearms at a sports or hunting trade show sponsored by a national, State, or local firearms trade organization devoted to the competitive use or other sporting use of firearms;
certain diplomats;
officials of foreign governments or distinguished foreign visitors so designated by the U.S. State Department;
foreign law enforcement officers of friendly foreign governments entering the United States on official law enforcement business; and
persons who have received a waiver from the prohibition from the U.S. Attorney General.
Significantly, even if a nonimmigrant alien falls within one of these exceptions, the nonimmigrant alien CANNOT purchase a firearm from a Federal firearms licensee (FFL) unless he or she (1) has an alien number or admission number from the Immigration and Naturalization Service AND (2) can provide the FFL with documentation showing that he or she has resided in a State within the United States for 90 days prior to the firearms transaction.
(A16) Q. Typically, who are "nonimmigrant aliens?"
In large part, nonimmigrant aliens are persons traveling temporarily in the United States for business or pleasure, persons studying in the United States who maintain a foreign residence abroad, and certain foreign workers. Permanent resident aliens are NOT nonimmigrant aliens. (Permanent resident aliens often are referred to as people with "Green Cards").