By 1874, Kelly was in control of Tammany Hall, and for the next decade, he was able to determine the course of New York City elections. In 1876, Kelly succeeded Andrew H. Green, appointed by Mayor William Wickham, as Comptroller of New York City. Kelly was very successful as comptroller. Over five years, the municipal debt was reduced by twelve million dollars. During his time in power he was continually at war with Tilden's faction. Kelly refused to support Tilden's candidate for governor, incumbent Lucius Robinson, and ran for governor himself as an independent. The result was the election in 1879 of Republican Alonzo Cornell, who won by a plurality. Kelly himself was city comptroller from 1876 to 1879. Upon retirement in 1884, he yielded his political control to one of his lieutenants, Richard Croker.