In 1800 Lloyd was elected to the Massachusetts House of Representatives, and in 1804 he won election to the state senate. In 1808, he won election to the United States Senate. The election, made by the state legislature, took place at an unusually early date, as it was designed as a snub of the sitting Federalist Senator, John Quincy Adams, for his support of the Embargo Act of 1807. Adams resigned his seat early, and Lloyd was appointed to fill the remainder of his term. He served until his resignation on May 1, 1813, due to poor health. On June 17, 1812, he voted against declaring war on Britain. On February 28, 1812, Lloyd gave a speech in the Senate of the United States on the Bill "Concerning the Naval Establishment".