Diplomatic immunity is a status granted to diplomatic personnel that exempts them from the laws of a foreign jurisdiction.
The Vienna Convention of Diplomatic Relations (1961), which most states have ratified, offers diplomats acting as officials of state almost total protection from subjection to criminal, administrative, and civil laws belonging to the country in which the diplomatic mission is located. Diplomats assigned to missions located in foreign countries remain subject to the laws of their home countries. The diplomat's country of origin has prerogative over whether or not a host country may prosecute a diplomat under its (i.e. 'foreign') laws.
The Diplomatic Relations Act of 1978, 22 U.S.C. § 254a et seq. governs diplomatic immunity in the United States. Title 22 specifies the degree of protection awarded to diplomatic personnel; protection increases in parallel with the official's status within a diplomatic mission. For more information about specific immunities granted to foreign diplomats residing in the U.S., see the U.S. State Department's chart of immunities and privileges.