An ardent secessionist, Wharton enlisted in the Confederate Army as captain of Company B, 8th Texas Cavalry, also known as "Terry's Texas Rangers." Commissioned as colonel of the regiment, Wharton fought with distinction at the Battle of Shiloh, where he was wounded. Wharton served under Gen. Braxton Bragg during the 1862 invasion of eastern Kentucky. He was promoted to brigadier general on November 18, 1862, and was again wounded, this time at Murfreesboro, Tennessee.