In 1902 he was elected as a Republican to the United States Senate, and served from March 4, 1903, to March 3, 1909. He failed to be renominated in 1908. He was chairman of the Committee on Coast and Insular Survey (Fifty-eighth and Fifty-ninth Congresses).
In 1867 he married Mary Jane (Jennie) Nesmith, daughter of Oregon Senator James W. Nesmith: they had five children.
Ankeny was member in Freemason order in Willamette Lodge No. 2, Portland, Oregon in 1866. He would later join Walla Walla Lodge No. 7 in 1878. He was also a member of Walla Walla Chapter No. 1, Royal Arch Masons, Washington Commandery No. 1, Knights Templar, Lawson Consistory, Ancient Accepted Scottish Rite and El Kalif Shrine in Spokane, Washington.
He worked in banking in Walla Walla until his death on March 29, 1921, and was interred at the Masonic Cemetery.