He served in the Maine House of Representatives from 1836 to 1841 then two terms in the U.S. House of Representatives (1843-1847). He was elected to fill a Senate vacancy in 1848 and to a full term in 1851.
A Democrat, Hamlin supported the candidacy of Franklin Pierce in 1852. However, he left the party over proslavery Democratic policies, and on June 12, 1856, he left the party and joined the Republicans. This caused a national sensation.
That same year Hamlin was elected the first Republican governor of Maine, but served less than a month before returning to the Senate. He was chosen for the second place on the Republican ticket in 1860. His identification with Radical elements of the party caused him to be dropped from the ticket in 1864.
There are biographies by his grandson Charles E. Hamlin (printed 1899, reprinted 1971) and H. D. Hunt (printed 1969).