He was chosen in a 1902 by-election to represent Victoria in the House of Commons of Canada, after the election of Edward Gawler Prior was voided. He was re-elected once, serving as an MP for Victoria City until 1906, when he resigned to allow William Templeman, a minister in Wilfrid Laurier's government, to take his seat. Shortly thereafter, Riley was appointed to the Senate.
