Gardner joined the Confederate Army as a lieutenant colonel in 1861. He helped lead the cavalry at the Battle of Shiloh. Afterward, for his leadership, he was promoted to brigadier general in April 1862. In December, he was promoted to major general. He commanded Confederate forces at Port Hudson, La., until July 1863. He was taken prisoner at the fall of Vicksburg. He was exchanged in August 1864, but he saw no further frontline duty for the remainder of the war.