He declined to accept a renomination in 1876. He served from March 4, 1875, to March 3, 1877.
In 1874, Ainsworth ran as a Democrat to represent Iowa's 3rd congressional district in the U.S. House. Becoming the first Iowa Democrat elected to Congress since 1854, he served in the Forty-fourth Congress.