The May revolution of 1682 placed Vasily Golitsyn at the head of the Posolsky Prikaz, or Ministry of Foreign Affairs, and during the regency (1682-1689) of Sophia (the half-sister of Peter the Great) whose intimate friend he became, he served as the principal minister of state (1682–1689) and as keeper of the great seal, a title bestowed upon only two Russians before him, Afanasy Ordin-Nashchokin (1605-1680) and Artamon Matveyev (1625-1682). In home affairs his influence was insignificant, but his foreign policy was distinguished by the Treaty of Nerchinsk (1689), which set the Russo-Chinese border north of the Amur River, and by the Eternal Peace Treaty of 1686 with Poland, whereby Russia at last definitively recovered Kiev. By the terms of the same treaty, Russia acceded to the grand league against the Porte, but Golitsyn's two expeditions against the Crimea (Crimean campaigns of 1687 and 1689) proved unsuccessful and made him extremely unpopular.