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).
Ranney's tenure as city counsel from 1855 to 1857 was followed by his involvement in state politics as a member of the Massachusetts House of Representatives in 1857, 1863, and 1864. He also represented the Republican Party in federal office during the Forty-seventh, Forty-eighth, and Forty-ninth Congresses (1881–1887).