MacRae enlisted as a private in the Monroe light infantry, and was elected captain when it became Company B, Fifteenth North Carolina infantry regiment. In April 1862, he was promoted to lieutenant colonel. During the Peninsula Campaign and at Second Manassas his regiment was a part of Howell Cobb's brigade. At the Battle of Antietam, MacRae commanded the brigade which had been reduced to 250 men during the fighting over the previous few weeks. MacRae's brigade repulsed three Union assaults but fell back when he had only 50 effectives remaining and his supply of ammunition was exhausted. At the Fredericksburg he fought with his regiment at Marye's Heights. Immediately following the battle the 15th North Carolina was transferred to Brigadier General John Rogers Cooke's North Carolina brigade. Cooke had been badly wounded at Fredericksburg and would not return to the brigade until April 1863. In February 1863, MacRae was promoted to colonel. This brigade served in North Carolina and southeast Virginia until after the Gettysburg Campaign. in February, 1863, colonel, and in 1864 was commissioned brigadier-general. After rejoining the Army of Northern Virginia, MacRae was distinguished for valor at the Battle of Bristoe Station. After Brigadier General William Whedbee Kirkland was wounded at the Battle of Cold Harbor MacRae was temporarily promoted to the rank of brigadier general and was assigned to the command of Kirkland's brigade (this was also the former brigade of Brigadier General J. Johnston Pettigrew). At the Ream's Station MacRae's, Lane's, and Cooke's brigades drove John Gibbon's 2nd Division of Winfield Scott Hancock's II Corps from its entrenchments in their front and captured an artillery battery. After meritorious service at the Battle of Boydton Plank Road MacRae remained with the army through the Appomattox Campaign.