18 USC 922 (paragraph (y)):
(y) Provisions Relating to Aliens Admitted Under Nonimmigrant Visas.—
(1) Definitions.—In this subsection—
(A) the term “alien” has the same meaning as in section 101(a)(3) of the Immigration and Nationality Act (8 U.S.C. 1101(a)(3)); and
(B) the term “nonimmigrant visa” has the same meaning as in section 101(a)(26) of the Immigration and Nationality Act (8 U.S.C. 1101(a)(26)).
(2) Exceptions.—Subsections (d)(5)(B), (g)(5)(B), and (s)(3)(B)(v)(II) [NOTE: these three exceptions all state it is illegal to sell/transfer to any alien here illegally or here on a NON-immigrant visa.]
do not apply to any alien who has been lawfully admitted to the United States under a nonimmigrant visa, if that alien is—
(A) admitted to the United States for lawful hunting or sporting purposes or is in possession of a hunting license or permit lawfully issued in the United States;
(B) an official representative of a foreign government who is—
(i) accredited to the United States Government or the Government’s mission to an international organization having its headquarters in the United States; or
(ii) en route to or from another country to which that alien is accredited;
(C) an official of a foreign government or a distinguished foreign visitor who has been so designated by the Department of State; or
(D) a foreign law enforcement officer of a friendly foreign government entering the United States on official law enforcement business.
(A) Conditions for waiver.—Any individual who has been admitted to the United States under a nonimmigrant visa may receive a waiver from the requirements of subsection (g)(5), if—
(i) the individual submits to the Attorney General a petition that meets the requirements of subparagraph (C); and
(ii) the Attorney General approves the petition.
(B) Petition.—Each petition under subparagraph (B) shall—
(i) demonstrate that the petitioner has resided in the United States for a continuous period of not less than 180 days before the date on which the petition is submitted under this paragraph; and
(ii) include a written statement from the embassy or consulate of the petitioner, authorizing the petitioner to acquire a firearm or ammunition and certifying that the alien would not, absent the application of subsection (g)(5)(B), otherwise be prohibited from such acquisition under subsection (g).
(C) Approval of petition.—The Attorney General shall approve a petition submitted in accordance with this paragraph, if the Attorney General determines that waiving the requirements of subsection (g)(5)(B) with respect to the petitioner—
(i) would be in the interests of justice; and
(ii) would not jeopardize the public safety.