 He was clerk of the Court of Appeals of Kansas from 1897 to 1901, and prosecuting attorney of Sedgwick County, Kansas, from 1906 to 1910.Ayres was elected as a Democrat to the Sixty-fourth, Sixty-fifth, and Sixty-sixth Congresses.He was an unsuccessful candidate for reelection in 1920 to the Sixty-seventh Congress.