During the Mexican-American War, he served in staff positions in New Orleans, and was promoted to first lieutenant on February 16, 1847. He learned of the outbreak of the Civil War while serving in California as a captain, to which he had been promoted to on May 9, 1855. Despite believing strongly that the Union should not be dissolved, he returned to Virginia to fight for his native state and the Confederacy.
During the Valley Campaign of 1862, Garnett's military career took a downward turn at the First Battle of Kernstown in March. Jackson marched his army to intercept a portion of the Union Army under Maj. Gen. Nathaniel P. Banks. On March 23, Jackson's cavalry commander, Col. Turner Ashby, brought faulty intelligence that the retreating Union division of Brig. Gen. James Shields had four regiments in the rear outside Winchester, Virginia. Since that force was of comparable size to Jackson's, he ordered Garnett and the Stonewall Brigade to attack. Unfortunately, Shields had a full infantry division on hand, almost 9,000 men, twice the size of Jackson's force. The attack went badly and Garnett, finding his brigade low on ammunition and surrounded by forces attacking from three sides, ordered a retreat. Jackson was infuriated and accused Garnett of disobeying orders, meaning that he should not have retreated without obtaining permission from Jackson first. Jackson, well-known as an overly strict disciplinarian, arrested Garnett for "neglect of duty" on April 1 and relieved him of command. Garnett's court-martial started in August 1862, with only Jackson and his aide giving testimony. However the trial was suspended due to the start of Gen. Robert E. Lee's Northern Virginia Campaign and the Second Battle of Bull Run that September.
Lee ordered Jackson to release Garnett from arrest and he was assigned to command the injured George Pickett's brigade in Lt. Gen. James Longstreet's First Corps in the Army of Northern Virginia. Garnett commanded the brigade credibly at the Battle of Antietam in September, after which he assumed permanent command of the brigade on November 26 when Pickett was promoted to divisional command, and at the Battle of Fredericksburg that December. He did not participate in the Battle of Chancellorsville in May 1863 because Longstreet's Corps was assigned duties in Suffolk, Virginia.
Stonewall Jackson was gravely wounded at Chancellorsville and died soon after from pneumonia. Upon Jackson's death, Garnett returned to Richmond where the general's body lay in state. Despite his professional disagreement with Jackson, Garnett held no ill will against him and was observed crying beside the casket. He then served as a pall bearer along with Longstreet, Richard S. Ewell, and others.
During the Gettysburg Campaign, Garnett's brigade continued in the division of George Pickett and, due to the order of march, did not reach the battlefield from Chambersburg, Pennsylvania, until late on the afternoon of July 2, 1863, missing the first two days of the Battle of Gettysburg. Pickett's division was assigned by Gen. Lee to lead a great assault on the Union's center on Cemetery Ridge on July 3. Garnett's brigade was in the front rank of Pickett's division, on the left, next to Brig. Gen. James L. Kemper's brigade. Garnett was in no shape to lead an infantry charge; he was suffering from fever and an injured leg when his horse kicked him and could not walk. But Garnett yearned to settle the record of his military dishonor from Kernstown, which the aborted court-martial could not. Despite protestations from other officers, Garnett insisted on leading his soldiers into battle on horseback, becoming a conspicuous target for Union riflemen.
Prior to starting out toward the Union defenses on Cemetery Hill, Garnett conversed with Brig. Gen. Lewis Armistead, another of Pickett's brigade commanders, about the proposed charge. Garnett reportedly said: "This is a desperate thing to attempt." to which Armistead added his prediction that "the slaughter will be terrible.
Garnett personally got to within 20 yards of the "Angle" on Cemetery Ridge and was never seen again. He presumably was hit by canister fire and his body was so badly damaged that it could not be identified afterward. His colleagues realized that he had been killed when his horse "Red Eye" returned to the Confederate lines on Seminary Ridge without him. Garnett (along with Armistead, Kemper and Isaac R. Trimble, who also made the charge) would be four of the 17 Confederate general officers lost during the three-day battle.