What is Diplomatic Immunity?

Legal Definition
Diplomatic immunity is a form of legal immunity that ensures diplomats are given safe passage and are considered not susceptible to lawsuit or prosecution under the host country's laws, although they can still be expelled. Modern diplomatic immunity was codified as international law in the Vienna Convention on Diplomatic Relations (1961) which has been ratified by all but a handful of nations, though the concept and custom of such immunity have a much longer history dating back thousands of years. Many principles of diplomatic immunity are now considered to be customary law. Diplomatic immunity as an institution developed to allow for the maintenance of government relations, including during periods of difficulties and armed conflict. When receiving diplomats, who formally represent the sovereign, the receiving head of state grants certain privileges and immunities to ensure they may effectively carry out their duties, on the understanding that these are provided on a reciprocal basis.

Originally, these privileges and immunities were granted on a bilateral, ad hoc basis, which led to misunderstandings and conflict, pressure on weaker states, and an inability for other states to judge which party was at fault. An international agreement known as the Vienna Conventions codified the rules and agreements, providing standards and privileges to all states.

It is possible for the official's home country to waive immunity; this tends to happen only when the individual has committed a serious crime, unconnected with their diplomatic role (as opposed to, say, allegations of spying), or has witnessed such a crime. However, many countries refuse to waive immunity as a matter of course; individuals have no authority to waive their own immunity (except perhaps in cases of defection). Alternatively, the home country may prosecute the individual. If immunity is waived by a government so that a diplomat (or their family members) can be prosecuted, it must be because there is a case to answer and it is in the public interest to prosecute them. For instance, in 2002, a Colombian diplomat in London was prosecuted for manslaughter, once diplomatic immunity was waived by the Colombian government.
-- Wikipedia
Legal Definition
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.
Legal Definition
the immunity that is given to representatives of foreign countries when they may break certain rules and regulations while working in this country.