
Buchanan had two notable absences from the country, both before his presidency, and both in diplomatic service. The first was in 1832, when Andrew Jackson appointed him to the position of Minister (or Ambassador) to Russia. Twelve years earlier, in 1820, Buchanan ran for the United States House of Representatives, calling himself a "Republican-Federalist." The Federalist Party had fallen apart after the end of the War of 1812. Buchanan had been a Federalist supporter, but he realized that he could never get elected as a candidate for that party. During his time in Congress, Buchanan abandoned any Federalist allegiances that he may have had, and became a supporter of Andrew Jackson. The two agreed strongly on the issue of states' rights. After the 1824 presidential election, Buchanan helped organize Jackson's followers into the Democratic Party, and Buchanan became a prominent Pennsylvania Democrat. In Washington, he became personally close with many southern Congressmen, including William Rufus King of Alabama, a man that some have speculated to be Buchanan's lover, though there is nothing more than suspicious circumstances and vague passages in letters to support this theory. Buchanan distrusted many of the New England Congressmen as dangerous radicals, especially those who were abolitionists. Buchanan eventually became Chairman of the U.S. House Committee on the Judiciary.
Buchanan served five terms as a member of the House, but declined re-nomination to a sixth term. He returned to private life practicing law only briefly. After Jackson's re-election in 1832, Jackson offered Buchanan the position of United States Ambassador to Russia. Buchanan was reluctant to leave the country, but ultimately he decided that it was his duty to accede to the Presidents wishes and he assented to the appointment.
Tsar Nicholas I succeeded his brother Alexander I to the throne in 1825. Nicholas had been a soldier and he had little or no interest in the arts. He was described as a "cold, no-nonsense autocrat" who gave little thought to political reforms. While Alexander had taken measures to improve and modernize Russia, and had even thought about creating a representative Parliament, much of this progress had been stalled by the landowning nobility.
Nicholas continued many of these administrative innovations, but sought to centralize more power in his own hands. His state security department (called the Third Section) became an instrument of repression, intended to put down subversive political activities. Nicholas had hoped that the Third Section would keep in heck the abuses of the wealthy and privileged, but many of the agency's officers saw their job as halting political and religious dissidents, often through violent means. Russia also suffered from a multitude of antiquated, contradictory, and discriminatory laws against Jews and minority Christian sects.
After the defeat of Napoleon, the Congress of Vienna in 1815 had partitioned Poland into Russian, Prussian, and Austrian "partitions." The increasingly repressive policies of the partitioning powers led to resistance movements in partitioned Poland, and in 1830 Polish patriots staged the November Uprising. This revolt developed into a full-scale war with Russia. Leadership in Poland was taken over by Polish conservatives who were reluctant to challenge the empire. The insurgent Polish National Government had been defeated by the Russian army in 1831. Poland lost its constitution and military, but formally remained a separate administrative unit within the Russian Empire. After the defeat of the November Uprising, thousands of former Polish combatants and other activists emigrated to Western Europe. Occupied Poland experienced repression at the hands of the Russians, and some Poles prepared for the next armed insurrection.
Buchanan served as ambassador for eighteen months. During that time he learned French (which was the language of diplomacy in the nineteenth century). As Ambassador to Russia, Buchanan helped negotiate to negotiate a number of commercial and maritime treaties with the Russian Empire. This was a remarkable accomplishment, as a number of previous ambassadors had been unable to successfully negotiate a treaty with the Russians. Buchanan was Ambassador to Russia when St. Petersburg was its capital. Nicholas I had ruled Russia through repression, but he and Buchanan seemed to develop a good relationship. (In Raising Buchanan, the title character claims that he "charmed the Tsar"). Buchanan was seen by some as an apologist for the Russian repression of Poland. He also defended the institution of serfdom in Russia as a benevolent program in which the serfs were better off under their conditions, much like the slavery that existed in the south.

When he returned to the United States in 1833, Buchanan was elected by the state legislature to succeed William Wilkins, the man who had replaced Buchanan as the ambassador to Russia, as the United States Senator from Pennsylvania. Buchanan would win re-election in 1836 and 1842. A solid Democrat and loyal supporter of Jackson, Buchanan opposed the re-chartering of the Second Bank of the United States and sought to expunge a congressional censure of Jackson stemming from the Bank War. Buchanan thought that the slavery was purely a state issue and he criticized abolitionists for exciting passions over the issue. In the lead-up to the 1844 Democratic National Convention, Buchanan positioned himself as a potential alternative to former President Martin Van Buren, but the nomination instead went to James K. Polk.