There are two types of resident spies: legals and illegals.
Legal resident
A 'legal resident' is a
spy who operates in a foreign country under
diplomatic cover (e.g. from his country's embassy). He is an official member of the diplomatic or consular staff, such as a commercial, cultural or military attaché. Thus he has
diplomatic immunity from prosecution and cannot be arrested by the host country if suspected of
espionage. The best the host country can do is send him back to his home country.
Illegal resident
An 'illegal resident' is a spy who operates in a foreign country but without the cover of his embassy. Thus he cannot claim immunity from prosecution when arrested. He usually operates under a false name and has documents making him out to be an actual national or from a friendly country. Examples of such illegals include
Rudolf Abel who operated in the
United States; and
Gordon Lonsdale who was born in
Russia, claimed to be
Canadian and operated in
Britain.