Hanna resumed his education after the war, studying law. He was admitted to the Illinois bar in 1866. Later, he moved to Council Bluffs, Iowa, where on September 21, 1869, he married Camilla Turley, a daughter of a prominent citizen there. He began his law practice in Council Bluffs as part of the firm Sapp, Lyman, and Hanna. At the end of his first year, when he was 23, he was appointed judge of the County Court, then in Council Bluffs. He held the office one and a half years and later served as city attorney for several years. He also served as deputy United States district attorney.