Ranney was in the corporation counsel for the city from 1855 to 1857. He was a member of the Massachusetts House of Representatives in 1857, 1863, and 1864 and served as a Republican in the Forty-seventh, Forty-eighth, and Forty-ninth Congresses (1881–1887). He failed reelection in 1886 to the Fiftieth Congress. He then resumed the practice of law until his death.
Rand, John Clark, A series of Biographical Sketches of One Thousand Representative Men Resident in the Commonwealth of Massachusetts. pages 500-501, (1890).