Espionage or spying is the act of obtaining secret or confidential information from non-disclosed sources or divulging of the same without the permission of the holder of the information. A person who commits espionage is called an espionage agent or spy.  Any individual or spy ring (a cooperating group of spies), in the service of a government, company, criminal organization, or independent operation, can commit espionage. The practice is clandestine, as it is by definition unwelcome. In some circumstances, it may be a legal tool of law enforcement and in others, it may be illegal and punishable by law.
Espionage is often part of an institutional effort by a government or commercial concern. However, the term tends to be associated with state spying on potential or actual enemies for military purposes. Spying involving corporations is known as industrial espionage.
One of the most effective ways to gather data and information about a targeted organization is by infiltrating its ranks. This is the job of the spy (espionage agent). Spies can then return information such as the size and strength of enemy forces. They can also find dissidents within the organization and influence them to provide further information or to defect. In times of crisis, spies steal technology and sabotage the enemy in various ways. Counterintelligence is the practice of thwarting enemy espionage and intelligence-gathering. Almost all nations have strict laws concerning espionage and the penalty for being caught is often severe. However, the benefits gained through espionage are often so great that most governments and many large corporations make use of it.
Main article: History of espionage
Espionage has been recognized as an importance in military affairs since ancient times.
The oldest known classified document was a report made by a spy disguised as a diplomatic envoy in the court of King Hammurabi, who died in around 1750 B.C. The Ancient Egyptians had a developed secret service and espionage is mentioned in the Iliad, the Bible, and the Amarna letters as well as its recordings in the story of the Old Testament, The Twelve Spies. Espionage was also prevalent in the Greco-Roman world, when spies employed illiterate subjects in civil services.
The thesis that espionage and intelligence has a central role in war as well as peace was first advanced in The Art of War and in the Arthashastra. In the Middle Ages European states excelled at what has later been termed counter-subversion when Catholic inquisitions were staged to annihilate heresy. Inquisitions were marked by centrally organised mass interrogations and detailed record keeping. During the Renaissance European states funded codebreakers to obtain intelligence through frequency analysis. Western espionage changed fundamentally during the Renaissance when Italian city-states installed resident ambassadors in capital cities to collect intelligence. Renaissance Venice became so obsessed with espionage that the Council of Ten, which was nominally responsible for security, did not even allow the doge to consult government archives freely. In 1481 the Council of Ten barred all Venetian government officials from making contact with ambassadors or foreigners. Those revealing official secrets could face the death penalty. Venice became obsessed with espionage because successful international trade demanded that the city-state could protect its trade secrets. Under Elizabeth I, Francis Walsingham was appointed foreign secretary and intelligence chief.
During the American Revolution, Nathan Hale and Benedict Arnold achieved their fame as spies, and there was considerable use of spies on both sides during the American Civil War. Though not a spy himself, George Washington was America's first spymaster, utilizing espionage tactics against the British.
In the 20th century, at the height of World War I, all great powers except the United States had elaborate civilian espionage systems and all national military establishments had intelligence units. In order to protect the country against foreign agents, the U.S. Congress passed the Espionage Act of 1917. Mata Hari, who obtained information for Germany by seducing French officials, was the most noted espionage agent of World War I. Prior to World War II, Germany and Imperial Japan established elaborate espionage nets. In 1942 the Office of Strategic Services was founded by Gen. William J. Donovan. However, the British system was the keystone of Allied intelligence. Numerous resistance groups such as the Austrian Maier-Messner Group, the French Resistance, the Witte Brigade, Milorg and the Polish Home Army worked against Nazi Germany and provided the Allied secret services with information that was very important for the war effort.
Since the end of World War II, the activity of espionage has enlarged, much of it growing out of the Cold War between the United States and the former USSR. The Russian Empire and its successor, the Soviet Union have had a long tradition of espionage ranging from the Okhrana to the KGB (Committee for State Security), which also acted as a secret police force. In the United States, the 1947 National Security Act created the Central Intelligence Agency (CIA) to coordinate intelligence and the National Security Agency for research into codes and electronic communication. In addition to these, the United States has 13 other intelligence gathering agencies; most of the U.S. expenditures for intelligence gathering are budgeted to various Defense Dept. agencies and their programs. Under the intelligence reorganization of 2004, the director of national intelligence is responsible for overseeing and coordinating the activities and budgets of the U.S. intelligence agencies.
In the Cold War, espionage cases included Alger Hiss and Whittaker Chambers and the Rosenberg Case. In 1952 the Communist Chinese captured two CIA agents, and in 1960 Francis Gary Powers, flying a U-2 reconnaissance mission over the Soviet Union for the CIA, was shot down and captured. During the Cold War, many Soviet intelligence officials defected to the West, including Gen. Walter Krivitsky, Victor Kravchenko, Vladimir Petrov, Peter Deriabin Pawel Monat, and Oleg Penkovsky, of the GRU (Soviet military intelligence). Among Western officials who defected to the Soviet Union are Guy Burgess and Donald D. Maclean of Great Britain in 1951, Otto John of West Germany in 1954, William H. Martin and Bernon F. Mitchell, U.S. cryptographers, in 1960, and Harold (Kim) Philby of Great Britain in 1962. U.S. acknowledgment of its U-2 flights and the exchange of Francis Gary Powers for Rudolf Abel in 1962 implied the legitimacy of some espionage as an arm of foreign policy.
China has a very cost-effective intelligence program that is especially effective in monitoring neighboring countries such as Mongolia, Russia, and India. Smaller countries can also mount effective and focused espionage efforts. For instance, the Vietnamese Communists had consistently superior intelligence during the Vietnam War. Some Islamic countries, including Libya, Iran, and Syria, have highly developed operations as well. SAVAK, the secret police of the Pahlavi dynasty, was particularly feared by Iranian dissidents before the 1979 Iranian Revolution.
Today, spy agencies target the illegal drug trade and terrorists as well as state actors. Between 2008 and 2011, the United States charged at least 57 defendants for attempting to spy for China.
Intelligence services value certain intelligence collection techniques over others. The former Soviet Union, for example, preferred human sources over research in open sources, while the United States has tended to emphasize technological methods such as SIGINT and IMINT. In the Soviet Union, both political (KGB) and military intelligence (GRU) officers were judged by the number of agents they recruited.
The espionage efforts and knowledge of a nation are often used by other countries by hiring their intelligence employees. The United Arab Emirates is one of the major countries relying on the technique, where they have hired the former employees of the US’ National Security Agency and the White House veterans. Some of the agents were hired to hack the Emirates’ former rival nation Qatar, its royals and even FIFA officials. Others were asked to conduct surveillance on other governments, human rights activists, social media critics, and even militants. However, the spying efforts of the UAE by using the Americans were also used to target the US itself, including former first lady Michelle Obama. 
In September 2021, three former intelligence officials from America admitted to working for the United Arab Emirates’ DarkMatter for hacking computers, servers, and electronic devices, including the computers and servers in the United States. According to court documents, the three operatives – Daniel Gericke, Ryan Adams, and Marc Baier – helped Emirati intelligence operatives with advanced cyber technology to assist them in breaches directed at potential enemies or political rivals. The DarkMatter also hired several other ex-N.S.A. and C.I.A. officers at salaries worth hundreds of thousands of dollars a year. 
Espionage agents are usually trained experts in a targeted field so they can differentiate mundane information from targets of value to their own organizational development. Correct identification of the target at its execution is the sole purpose of the espionage operation.
Broad areas of espionage targeting expertise include:
Although the news media may speak of "spy satellites" and the like, espionage is not a synonym for all intelligence-gathering disciplines. It is a specific form of human source intelligence (HUMINT). Codebreaking (cryptanalysis or COMINT), aircraft or satellite photography, (IMINT) and analysis of publicly available data sources (OSINT) are all intelligence gathering disciplines, but none of them is considered espionage. Many HUMINT activities, such as prisoner interrogation, reports from military reconnaissance patrols and from diplomats, etc., are not considered espionage. Espionage is the disclosure of sensitive information (classified) to people who are not cleared for that information or access to that sensitive information.
Unlike other forms of intelligence collection disciplines, espionage usually involves accessing the place where the desired information is stored or accessing the people who know the information and will divulge it through some kind of subterfuge. There are exceptions to physical meetings, such as the Oslo Report, or the insistence of Robert Hanssen in never meeting the people who bought his information.
The US defines espionage towards itself as "the act of obtaining, delivering, transmitting, communicating, or receiving information about the national defence with an intent, or reason to believe, that the information may be used to the injury of the United States or to the advantage of any foreign nation". Black's Law Dictionary (1990) defines espionage as: "... gathering, transmitting, or losing ... information related to the national defense". Espionage is a violation of United States law, 18 U.S.C. §§ 792–798 and Article 106a of the Uniform Code of Military Justice". The United States, like most nations, conducts espionage against other nations, under the control of the National Clandestine Service. Britain's espionage activities are controlled by the Secret Intelligence Service.
A spy is a person employed to seek out top secret information from a source. Within the United States Intelligence Community, "asset" is more common usage. A case officer or Special Agent, who may have diplomatic status (i.e., official cover or non-official cover), supports and directs the human collector. Cut-outs are couriers who do not know the agent or case officer but transfer messages. A safe house is a refuge for spies. Spies often seek to obtain secret information from another source.
In larger networks, the organization can be complex with many methods to avoid detection, including clandestine cell systems. Often the players have never met. Case officers are stationed in foreign countries to recruit and supervise intelligence agents, who in turn spy on targets in the countries where they are assigned. A spy need not be a citizen of the target country—hence does not automatically commit treason when operating within it. While the more common practice is to recruit a person already trusted with access to sensitive information, sometimes a person with a well-prepared synthetic identity (cover background), called a legend in tradecraft, may attempt to infiltrate a target organization.
These agents can be moles (who are recruited before they get access to secrets), defectors (who are recruited after they get access to secrets and leave their country) or defectors in place (who get access but do not leave).
A legend is also employed for an individual who is not an illegal agent, but is an ordinary citizen who is "relocated", for example, a "protected witness". Nevertheless, such a non-agent very likely will also have a case officer who will act as a controller. As in most, if not all synthetic identity schemes, for whatever purpose (illegal or legal), the assistance of a controller is required.
Spies may also be used to spread disinformation in the organization in which they are planted, such as giving false reports about their country's military movements, or about a competing company's ability to bring a product to market. Spies may be given other roles that also require infiltration, such as sabotage.
Many governments spy on their allies as well as their enemies, although they typically maintain a policy of not commenting on this. Governments also employ private companies to collect information on their behalf such as SCG International Risk, International Intelligence Limited and others.
Many organizations, both national and non-national, conduct espionage operations. It should not be assumed that espionage is always directed at the most secret operations of a target country. National and terrorist organizations and other groups are also targeted. This is because governments want to retrieve information that they can use to be proactive in protecting their nation from potential terrorist attacks.
Communications both are necessary to espionage and clandestine operations, and also a great vulnerability when the adversary has sophisticated SIGINT detection and interception capability. Spies rely on COVCOM or covert communication through technically advanced spy devices. Agents must also transfer money securely.
Main article: Industrial espionage
Reportedly Canada is losing $12 billion and German companies are estimated to be losing about €50 billion ($87 billion) and 30,000 jobs to industrial espionage every year.
In espionage jargon, an "agent" is the person who does the spying. They may be a citizen of a country recruited by that country to spy on another; a citizen of a country recruited by that country to carry out false flag assignments disrupting his own country; a citizen of one country who is recruited by a second country to spy on or work against his own country or a third country, and more.
In popular usage, this term is sometimes confused with an intelligence officer, intelligence operative or case officer who recruits and handles agents.
Among the most common forms of agent are:
Less common or lesser known forms of agent include:
Espionage against a nation is a crime under the legal code of many nations. In the United States, it is covered by the Espionage Act of 1917. The risks of espionage vary. A spy violating the host country's laws may be deported, imprisoned, or even executed. A spy violating its own country's laws can be imprisoned for espionage or/and treason (which in the United States and some other jurisdictions can only occur if they take up arms or aids the enemy against their own country during wartime), or even executed, as the Rosenbergs were. For example, when Aldrich Ames handed a stack of dossiers of U.S. Central Intelligence Agency (CIA) agents in the Eastern Bloc to his KGB-officer "handler", the KGB "rolled up" several networks, and at least ten people were secretly shot. When Ames was arrested by the U.S. Federal Bureau of Investigation (FBI), he faced life in prison; his contact, who had diplomatic immunity, was declared persona non grata and taken to the airport. Ames' wife was threatened with life imprisonment if her husband did not cooperate; he did, and she was given a five-year sentence. Hugh Francis Redmond, a CIA officer in China, spent nineteen years in a Chinese prison for espionage—and died there—as he was operating without diplomatic cover and immunity.
In United States law, treason, espionage, and spying are separate crimes. Treason and espionage have graduated punishment levels.
The United States in World War I passed the Espionage Act of 1917. Over the years, many spies, such as the Soble spy ring, Robert Lee Johnson, the Rosenberg ring, Aldrich Hazen Ames, Robert Philip Hanssen, Jonathan Pollard, John Anthony Walker, James Hall III, and others have been prosecuted under this law.
From ancient times, the penalty for espionage in many countries was execution. This was true right up until the era of World War II; for example, Josef Jakobs was a Nazi spy who parachuted into Great Britain in 1941 and was executed for espionage.
In modern times, many people convicted of espionage have been given penal sentences rather than execution. For example, Aldrich Hazen Ames is an American CIA analyst, turned KGB mole, who was convicted of espionage in 1994; he is serving a life sentence without the possibility of parole in the high-security Allenwood U.S. Penitentiary. Ames was formerly a 31-year CIA counterintelligence officer and analyst who committed espionage against his country by spying for the Soviet Union and Russia. So far as it is known, Ames compromised the second-largest number of CIA agents, second only to Robert Hanssen, who is also serving a prison sentence.
Espionage laws are also used to prosecute non-spies. In the United States, the Espionage Act of 1917 was used against socialist politician Eugene V. Debs (at that time the Act had much stricter guidelines and amongst other things banned speech against military recruiting). The law was later used to suppress publication of periodicals, for example of Father Coughlin in World War II. In the early 21st century, the act was used to prosecute whistleblowers such as Thomas Andrews Drake, John Kiriakou, and Edward Snowden, as well as officials who communicated with journalists for innocuous reasons, such as Stephen Jin-Woo Kim.
As of 2012[update], India and Pakistan were holding several hundred prisoners of each other's country for minor violations like trespass or visa overstay, often with accusations of espionage attached. Some of these include cases where Pakistan and India both deny citizenship to these people, leaving them stateless. The BBC reported in 2012 on one such case, that of Mohammed Idrees, who was held under Indian police control for approximately 13 years for overstaying his 15-day visa by 2–3 days after seeing his ill parents in 1999. Much of the 13 years were spent in prison waiting for a hearing, and more time was spent homeless or living with generous families. The Indian People's Union for Civil Liberties and Human Rights Law Network both decried his treatment. The BBC attributed some of the problems to tensions caused by the Kashmir conflict.
Espionage is illegal in the UK under the Official Secrets Acts of 1911 and 1920. The UK law under this legislation considers espionage as "concerning those who intend to help an enemy and deliberately harm the security of the nation". According to MI5, a person commits the offence of 'spying' if they, "for any purpose prejudicial to the safety or interests of the State": approaches, enters or inspects a prohibited area; makes documents such as plans that are intended, calculated, or could directly or indirectly be of use to an enemy; or "obtains, collects, records, or publishes, or communicates to any other person any secret official code word, or password, or any sketch, plan, model, article, or note, or other document which is calculated to be or might be or is intended to be directly or indirectly useful to an enemy". The illegality of espionage also includes any action which may be considered 'preparatory to' spying, or encouraging or aiding another to spy.
Under the penal codes of the UK, those found guilty of espionage are liable to imprisonment for a term of up to 14 years, although multiple sentences can be issued.
Government intelligence is very much distinct from espionage, and is not illegal in the UK, providing that the organisations of individuals are registered, often with the ICO, and are acting within the restrictions of the Regulation of Investigatory Powers Act (RIPA). 'Intelligence' is considered legally as "information of all sorts gathered by a government or organisation to guide its decisions. It includes information that may be both public and private, obtained from much different public or secret sources. It could consist entirely of information from either publicly available or secret sources, or be a combination of the two."
However, espionage and intelligence can be linked. According to the MI5 website, "foreign intelligence officers acting in the UK under diplomatic cover may enjoy immunity from prosecution. Such persons can only be tried for spying (or, indeed, any criminal offence) if diplomatic immunity is waived beforehand. Those officers operating without diplomatic cover have no such immunity from prosecution".
There are also laws surrounding government and organisational intelligence and surveillance. Generally, the body involved should be issued with some form of warrant or permission from the government and should be enacting their procedures in the interest of protecting national security or the safety of public citizens. Those carrying out intelligence missions should act within not only RIPA but also the Data Protection Act and Human Rights Act. However, there are spy equipment laws and legal requirements around intelligence methods that vary for each form of intelligence enacted.
In war, espionage is considered permissible as many nations recognize the inevitability of opposing sides seeking intelligence each about the dispositions of the other. To make the mission easier and successful, combatants wear disguises to conceal their true identity from the enemy while penetrating enemy lines for intelligence gathering. However, if they are caught behind enemy lines in disguises, they are not entitled to prisoner-of-war status and subject to prosecution and punishment—including execution.
The Hague Convention of 1907 addresses the status of wartime spies, specifically within "Laws and Customs of War on Land" (Hague IV); October 18, 1907: CHAPTER II Spies". Article 29 states that a person is considered a spy who, acts clandestinely or on false pretences, infiltrates enemy lines with the intention of acquiring intelligence about the enemy and communicate it to the belligerent during times of war. Soldiers who penetrate enemy lines in proper uniforms for the purpose of acquiring intelligence are not considered spies but are lawful combatants entitled to be treated as prisoners of war upon capture by the enemy. Article 30 states that a spy captured behind enemy lines may only be punished following a trial. However, Article 31 provides that if a spy successfully rejoined his own military and is then captured by the enemy as a lawful combatant, he cannot be punished for his previous acts of espionage and must be treated as a prisoner of war. Note that this provision does not apply to citizens who committed treason against their own country or co-belligerents of that country and may be captured and prosecuted at any place or any time regardless whether he rejoined the military to which he belongs or not or during or after the war.
The ones that are excluded from being treated as spies while behind enemy lines are escaping prisoners of war and downed airmen as international law distinguishes between a disguised spy and a disguised escaper. It is permissible for these groups to wear enemy uniforms or civilian clothes in order to facilitate their escape back to friendly lines so long as they do not attack enemy forces, collect military intelligence, or engage in similar military operations while so disguised. Soldiers who are wearing enemy uniforms or civilian clothes simply for the sake of warmth along with other purposes rather than engaging in espionage or similar military operations while so attired are also excluded from being treated as unlawful combatants.
Saboteurs are treated as spies as they too wear disguises behind enemy lines for the purpose of waging destruction on an enemy's vital targets in addition to intelligence gathering. For example, during World War II, eight German agents entered the U.S. in June 1942 as part of Operation Pastorius, a sabotage mission against U.S. economic targets. Two weeks later, all were arrested in civilian clothes by the FBI thanks to two German agents betraying the mission to the U.S. Under the Hague Convention of 1907, these Germans were classified as spies and tried by a military tribunal in Washington D.C. On August 3, 1942, all eight were found guilty and sentenced to death. Five days later, six were executed by electric chair at the District of Columbia jail. Two who had given evidence against the others had their sentences reduced by President Franklin D. Roosevelt to prison terms. In 1948, they were released by President Harry S. Truman and deported to the American Zone of occupied Germany.
The U.S. codification of enemy spies is Article 106 of the Uniform Code of Military Justice. This provides a mandatory death sentence if a person captured in the act is proven to be "lurking as a spy or acting as a spy in or about any place, vessel, or aircraft, within the control or jurisdiction of any of the armed forces, or in or about any shipyard, any manufacturing or industrial plant, or any other place or institution engaged in work in aid of the prosecution of the war by the United States, or elsewhere".
Main article: Spy fiction
Spies have long been favourite topics for novelists and filmmakers. An early example of espionage literature is Kim by the English novelist Rudyard Kipling, with a description of the training of an intelligence agent in the Great Game between the UK and Russia in 19th century Central Asia. An even earlier work was James Fenimore Cooper's classic novel, The Spy, written in 1821, about an American spy in New York during the Revolutionary War.
During the many 20th-century spy scandals, much information became publicly known about national spy agencies and dozens of real-life secret agents. These sensational stories piqued public interest in a profession largely off-limits to human interest news reporting, a natural consequence of the secrecy inherent in their work. To fill in the blanks, the popular conception of the secret agent has been formed largely by 20th and 21st-century fiction and film. Attractive and sociable real-life agents such as Valerie Plame find little employment in serious fiction, however. The fictional secret agent is more often a loner, sometimes amoral—an existential hero operating outside the everyday constraints of society. Loner spy personalities may have been a stereotype of convenience for authors who already knew how to write loner private investigator characters that sold well from the 1920s to the present.
Johnny Fedora achieved popularity as a fictional agent of early Cold War espionage, but James Bond is the most commercially successful of the many spy characters created by intelligence insiders during that struggle. His less fantastic rivals include Le Carre's George Smiley and Harry Palmer as played by Michael Caine. '
Jumping on the spy bandwagon, other writers also started writing about spy fiction featuring female spies as protagonists, such as The Baroness, which has more graphic action and sex, as compared to other novels featuring male protagonists.
Spy fiction has also permeated the video game world, in such games as Perfect Dark, GoldenEye 007, No One Lives Forever 1 and 2, and the Metal Gear series.
Espionage has also made its way into comedy depictions. The 1960s TV series Get Smart, the 1983 Finnish film Agent 000 and the Deadly Curves, and Johnny English film trilogy portrays an inept spy, while the 1985 movie Spies Like Us depicts a pair of none-too-bright men sent to the Soviet Union to investigate a missile.
The historical novel The Emperor and the Spy highlights the adventurous life of U.S. Colonel Sidney Forrester Mashbir, who during the 1920s and 1930s attempted to prevent war with Japan, and when war did erupt, he became General MacArthur's top advisor in the Pacific Theater of World War Two.
Black Widow is also a fictional agent who was introduced as a Russian spy, an antagonist of the superhero Iron Man. She later became an agent of the fictional spy agency S.H.I.E.L.D. and a member of the superhero team the Avengers.