In 1975, Putin joined the staff of the First Chief Directorate for Foreign Intelligence of the KGB, and was assigned to the Leningrad branch, where until 1978 he helped to shadow foreign visitors. In 1985, he was assigned to counterintelligence duties in Dresden (in then-East Germany), where he served for five years. Reportedly, he checked the loyalty of Soviet diplomats and other personnel and recruited secret informants who could report on North Atlantic Treaty Organization (NATO) affairs. In 1990, he returned to Leningrad after the collapse of East Germany and assumed the post of Assistant Rector (Dean) for International Affairs at Leningrad State University, working for his former teacher, Rector Anatoliy Sobchak. Reportedly, there he also checked on the loyalty of students and monitored foreigners. In 1991, upon Sobchak's election as Chairman of the Leningrad City Council, Putin became his advisor, and retired from the KGB with the rank of lieutenant colonel. From 1991–1994, Putin was chairman of the Foreign Relations Committee of the City Council, and in 1992–1994 was also the deputy mayor of St. Petersburg. From 1994–1996, Putin was appointed First Deputy Chairman of the City Council (renamed First Deputy Mayor of St. Petersburg).
When Sobchak lost a re-election bid in 1996, Putin asked his Moscow friends for help in finding a job, and Pavel Borodin, head of the State Property Administration under the Russian Presidency, brought Putin to Moscow to work as his deputy business manager. In this post, Putin gained major recognition as an efficient and discrete manager of presidential assets and properties, such as dachas, limousines, hospitals, and spas. Success led to his being appointed head of the Presidential Administration and chief of the Control (disbursing) Department of the Presidency from 1997–1998. In 1998, he was named director of the Federal Security Service (counterintelligence agency), and from March 1999 until August 1999, was also the secretary of the Russia Security Council, the top national security decision-making body, headed by the president. On 9 August 1999, Yeltsin appointed him acting prime minister, and on 16 August 1999, he was confirmed by the legislature.
In 1999, President Yeltsin faced increasing scandal as international investigations seemingly pointed to his family's involvement in financial crimes. He resigned on 31 December 1999, a few months before his term would normally end. He had appointed Putin as prime minister in August 1999, and hailed him as his choice for the presidency. Early presidential elections were scheduled for 26 March 2000. Some observers speculate that Yeltsin and his supporters viewed Putin as a capable leader who would be able to shield Yeltsin from prosecution for corruption. They note that Putin's first move after being appointed acting president was to sign a decree granting Yeltsin immunity from prosecution.
During the March 2000 presidential election, Putin refused to outline his policy program in any detail or debate other candidates, but took positions on some issues. He called for a strong and stable Russia, fighting crime, and law and order (exemplified by fighting Chechen terrorists). He stressed that "the stronger the state, the freer the individual," trying to equate safety and freedom. He also argued that a strong state is "part of Russia's genetic code." His other major campaign themes and promises included creating a level playing field in economy with no favors for oligarchs; raising pensions to seniors from US $25 to $35 as a moral necessity; making an inventory of Russia's resources and assets; retaining some nationalized defense industries; and increasing support for the armed forces and defense industries. He also stressed the need for low taxes that are widely collected, rather than high taxes that are rarely collected, and land reform (though he was vague on private property rights). Putin's vague promises and themes aimed at a middle-of-the-road, inclusive campaign that did not alienate possible constituencies. A slight decline in Putin's lead near election day led pro-Putin media to launch an ominous anti-Semitic attack against liberal Yabloko Party candidate Grigoriy Yavlinskiy, and Putin put added pressure on regional leaders to deliver votes for him. According to officially reported results, Putin squeaked to a victory in the first round, something Yeltsin was not able to do in 1996. The Central Electoral Commission reported that Putin gained about 53% of 75.2 million votes cast.