Origins and makeup
The XVIII Corps was created on December 24, 1862. It was initially composed of five divisions stationed in North Carolina, making it one of the largest in the Union Army (though two were detached to join the X Corps in early 1863), and placed under the command of General John G. Foster. By August 1863, most of the corps' original units were either disbanded or transferred elsewhere, but Brig. Gen. George W. Getty's division (formerly of IX Corps) and the bulk of the recently discontinued VII Corps from Virginia were redesignated the XVIII Corps.
During the spring of 1864, the corps—now commanded by General William Farrar Smith, formerly of VI Corps—was transferred to Yorktown, Virginia, to join Maj. Gen. Benjamin Butler's Army of the James. The corps played a major part in the unsuccessful operations in the Bermuda Hundred, and was also heavily engaged at Cold Harbor. On June 12, Lt. Gen. Ulysses S. Grant sent Smith on a surprise march to seize Petersburg from the Confederate forces before Robert E. Lee could bring up the bulk of the Army of Northern Virginia. In the Second Battle of Petersburg, June 15-18, 1864, Smith made successful initial attacks against the outnumbered defenses of Gen. P.G.T. Beauregard; but after driving Beauregard's men from their outer entrenchments on the 15th, Smith, fearful of a Confederate counterattack, lost his nerve and did not press the attack when it could have resulted in the easy seizure of the city.
Smith was relieved of command in July due to ill health, and he was replaced by Edward O.C. Ord and later Godfrey Weitzel. Charles A. Heckman briefly commanded the corps following the wounding of General Ord during the Battle of Chaffin's Farm. John Gibbon was temporary commander of the corps in the month of September 1864. The corps occupied the line of entrenchments closest to the main Confederate line, and suffered heavy casualties in almost daily skirmishing for a month. The corps was relieved of its position by X Corps on August 26, and the corps was sent first to the Bermuda Hundred, and later to the north bank of the James River. Its first division took part in the successful attack on Fort Harrison on August 29 during the Battle of Chaffin's Farm. The corps was also engaged on October 27 in the Second Battle of Fair Oaks, fought over the same ground as the first battle in May 1862. The corps was ultimately discontinued in December 1864; as with X Corps, its white units went to join the new XXIV Corps, while its black units joined XXV Corps.