Magruder enlisted in the Confederate States Army at age 17 and served under General Simon Bolivar Buckner at the Battle of Fort Donelson. He was captured when Buckner chose to surrender the fort rather than allow his men to fight their way out, but he soon escaped. Magruder joined the personal bodyguard of Confederate General Albert Sidney Johnston, serving under him at the Battle of Shiloh. Following General Johnston's death, Magruder transferred to General John Hunt Morgan's Kentucky Cavalry. He took part in Morgan's raid into Ohio and Indiana; and once again escaped capture. He was eventually able to cross the Ohio River back into Kentucky.