Walsh served as a member of the Maryland Constitutional convention in 1867, and was later elected as a Democrat to the Forty-fourth and Forty-fifthCongresses (serving from March 4, 1875, until March 3, 1879). In Congress, he served as chairman of the Committee on Revision of the Laws (Forty-fifth Congress), but declined to be a candidate for renomination in 1878. He resumed the practice of law afterwards, and died in Cumberland in 1892. Walsh is interred in St. Patrick's Cemetery.