 Federalist leaders in Massachusetts arranged for Adams's election to the United States Senate in 1802, but Adams broke with the Federalist Party over foreign policy and was denied re-election.In 1809, Adams was appointed as the U.S. ambassador to Russia by President James Madison, a member of the Democratic-Republican Party.Adams held diplomatic posts for the duration of Madison's presidency, and he served as part of the American delegation that negotiated an end to the War of 1812.