 While living in Kentucky, Hayes studied law and was admitted to the bar in Kentucky, before returning to Baltimore in 1872.Hayes was elected to the Maryland House of Delegates, serving in the 1880 session, and served in the Maryland Senate in 1884 and 1886.On June 1, 1886, President Grover Cleveland appointed Hayes as the United States District Attorney for Maryland.