Espionage is the practice of obtaining information about an organization or a society that is considered secret or confidential (spying) without the permission of the holder of the information. What differentiates espionage from other forms of intelligence work is that espionage involves obtaining the information by accessing the place where the information is stored or accessing the people who know the information and will divulge it through some kind of subterfuge.
Espionage is usually thought of as part of an institutional effort (i.e., governmental or corporate espionage). The term espionage is most readily associated with state spying on potential or actual enemies, primarily for military purposes, but this has been extended to spying involving corporations, known specifically as industrial espionage. Many nations routinely spy on both their enemies and allies, although they maintain a policy of not making comment on this. In addition to utilizing agencies within a government many also employ private companies to collect information on their behalf such as SCG International Risk and others. Black's Law Dictionary (1990) defines espionage as: "...gathering, transmitting, or losing...information related to the national defence."
A spy is a person employed to obtain such secrets. The term intelligence officer is also used to describe a member of the armed forces, police, or civilian intelligence agency who specialises in the gathering, fusion, and analysis of information and intelligence in order to provide advice to their government or another organisation. In general, intelligence officers travel to foreign countries to recruit and "run" intelligence agents, who in turn spy on their own governments. These agents can be moles (who are recruited before they get access to secrets) or defectors (who are recruited after they get access to secrets).
The risks vary. An officer may be breaking the host country's laws and can be deported or imprisoned. An agent breaking his/her own country's laws can be imprisoned for espionage or even executed for treason. For example, when Aldrich Ames handed a stack of dossiers of CIA agents 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 FBI, he faced life in prison; his contact, who had diplomatic immunity, was declared persona non grata and taken to the airport. In the vernacular, he was "PNGed" (pronounced "pinged"). Ames's 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: he was an "illegal," operating without diplomatic cover.
Spymaster is a term often used in literature for the superior of a spy ring.
History of Espionage
Incidents of espionage are well documented throughout history. The ancient writings of Chinese and Indian military strategists such as Sun-Tzu and Chanakya contain information on deception and subversion. Chanakya's student Chandragupta Maurya, founder of the Maurya Empire, made use of assassinations, spies and secret agents, which are described in Chanakya's Arthasastra. The ancient Egyptians had a thoroughly developed system for the acquisition of intelligence, and the Hebrews used spies as well, as in the story of Rahab. Feudal Japan often used ninja to gather intelligence. More recently, they played a significant part in Elizabethan England (see Francis Walsingham). Many modern espionage methods were well established even then. 
The Cold War involved intense espionage activity between the United States of America and its allies and the Soviet Union and the People's Republic of China and their allies, particularly related to nuclear weapons secrets. Recently, espionage agencies have targeted the illegal drug trade and those considered to be terrorists.
For three decades the United States has cultivated its best and brightest to pre-eminence in what is now known as the field of communication and control. As technology has advanced, the means and methods of espionage have advanced from Nixon era wire tapping, through Reagan era programs like ECHELON and Carnivore, to surveillance of all electronic transmissions including cell phone logs, voice mail, email, packet sniffing, trace routing and wireless transmissions.
However, the Soviet Union has been said to have had fielded the largest and most advanced spy networks during its time, infiltrating some of the most secure places on the planet, which has caused many scandals.
Since January of 2000, a long list of agencies have been data mining the world's stock exchanges; this program was formalized on October 26, 2001 in the form of the Patriot Act. This helps track the financing of people who might be laundering money from drug transactions. For a variety of reasons, including changes in technology, it has been necessary to do this without warrants and it is argued that the necessity makes it legal.
In order to gather political and economic information that might be of advantage to the United States, foreign communications are routinely subject to surveillance. In 2002, new programs of satellite surveillance and unmanned low level drones armed with missiles made it possible not only to perform surveillance in real time, but to respond with force.