In espionage, a resident spy is an agent operating within a foreign country for extended periods of time. A base of operations within a foreign country which a resident spy may liaise with is known as a station in United States parlance and a rezidentura (residency) in Russian parlance; accordingly, what the U.S. would call a station chief, the head spy, is known as a rezident in Russian.
Types of resident spies
In the former U.S.S.R. and Russian nomenclature, there are two types of resident spies: legal'nye rezidenty (легальне резиденты, legal resident spy) and nelegal'nye rezidenty (нелегальне резиденты, illegal resident spy). In U.S. parlance the same distinction is between official cover and non-official cover.
A legal resident spy operates in a foreign country under official cover (e.g. from his country's embassy). He is an official member of the 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 most the host country can do is send him back to his home country as persona non grata.
An illegal resident spy operates under a non-official cover; thus, he cannot claim immunity from prosecution when arrested. He may operate under a false name and has documents making him out to be an actual national or from a different country to that which he is spying for. 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. Famous Soviet "illegals" include Richard Sorge, Walter Krivitsky, Alexander Ulanovsky, and Anna Chapman, who is also known as a sleeper agent.
Comparison of illegal and legal resident spies
The advantages and disadvantages of legal resident spies mostly mirror the disadvantages and advantages of illegal resident spies. A legal resident spy has the advantage of diplomatic status, but the disadvantage of being a known foreigner to the host country and one of just a few official diplomatic staff, whose intelligence status is thus easy for counterintelligence agencies to discern; whereas an illegal resident spy has the advantage of being unknown as a foreigner to the host country and one amongst millions of the country's ordinary citizens, but the disadvantage of not having diplomatic immunity to fall back upon. A legal resident spy has opportunities to meet high-level personnel of the host country as part of his/her "official" business, whereas an illegal resident spy does not. But, conversely, illegal resident spies have easier access to a wide range of potential sources who would be put off by having to approach and deal with an openly foreign official, and indeed need not even reveal to those people what country he/she actually works for.
Furthermore: An illegal resident spy can stay in the host country when diplomatic relations break down, whereas legal resident spies are forced to leave with the diplomatic mission. But a legal resident spy is easier to pay, since his/her salary can be openly incorporated into the diplomatic payroll, whereas making arrangements to pay illegal resident spies can be difficult, sometimes involving ruses, more expensive and complex to administer than paying a diplomatic official would be, such as paying a host country organization or corporation to allow the illegal resident spy to pose as a member of its staff and be nominally paid by that organization/corporation.
A legal resident spy has full and aboveboard access to embassy facilities, for secure communications, meetings, and other services; whereas an illegal resident spy has little to no access to such facilities, and communications arrangements are thus more difficult and time consuming. An illegal resident spy will usually have a falsified biography; whereas a legal resident spy may suffer from having an official biography, documenting his/her diplomatic career and providing useful clues to counterintelligence services about his/her intelligence activities and connections.