As a lieutenant colonel, Hays commanded a brigade of horse artillery under Henry Hunt in 1861–62 in the Army of the Potomac, serving with distinction at the Battle of Seven Pines during the Peninsula Campaign. He participated in the Battle of Antietam, where he commanded the V Corps Reserve Artillery. His batteries were stationed on the heights east of Antietam Creek, providing long range fire against Confederate infantry positions between the East and West Woods. He commanded the artillery of the Right Grand Division at Fredericksburg. Hays was appointed brigadier general of volunteers in November 1862 and assigned command of an infantry brigade in Maj. Gen. William H. French's division in the II Corps. He was wounded and taken prisoner at Chancellorsville on May 3, 1863, along with all but one of his immediate staff. Hays was exchanged on May 15, 1863, and sent to Fort Monroe in Virginia. Although without an official command, he rejoined the Army of the Potomac and accompanied it to Gettysburg, Pennsylvania. During Pickett's Charge on July 3, Maj. Gen. Winfield S. Hancock was severely wounded but refused to leave the field until the battle had been decided. When it became clear the Confederate charge had been defeated Hancock relinquished command temporarily to his 1st Division commander, Brig. Gen. John C. Caldwell. Later that evening, Hays, was assigned to command the II Corps. He led the corps throughout the summer until permanent command was given to Maj. Gen. Gouverneur K. Warren in mid-September. In November, Hays was appointed provost marshal of the southern district of New York, and was also promoted to major in the regular army. At the expiration of his term in February 1865, Hays rejoined the Army of the Potomac at Petersburg and served again in the II Corps, this time commanding the 2nd Division. He was appointed a brevet brigadier general in the regular army on March 13, 1865, for gallant conduct, but on April 6 he was relieved of command for sleeping on duty and thus failing to prepare his troops for departure as they pursued Confederate forces. His brevets were revoked and Brig. Gen. Francis C. Barlow was assigned to lead the division. From that date, Hays commanded the Artillery Reserve of the Army of the Potomac until he was mustered out of volunteer service in January 1866.
Later life
Reverting to his permanent rank of major of the 5th U.S. Artillery, Hays served on various posts, commanding Fort Independence in Boston Harbor from April 1873 until his death there almost two years later. He was buried in Yonkers, New York, but was re-interred at West Point Cemetery in 1894.