Harlan represented the state of Iowa in the Senate as a member of the Free Soil Party, in 1855. In 1857, the Senate declared the seat vacant because of irregularities in the legislative proceedings that first elected Harlan to the Senate. He was then re-elected to the Senate by the Iowa legislature as a Republican and continued to hold the Senate seat until 1865 when he resigned to become Secretary of the Interior under President Andrew Johnson, an office he held until 1866. Harlan was elected again to the Senate in 1867 and served until 1873.
From 1853 to 1855, Harlan was president of Iowa Wesleyan University in Mount Pleasant, Iowa.
Harlan was a good friend of the Lincoln family. In 1868 his daughter, Mary Eunice Harlan, married Robert Todd Lincoln.