During the Gettysburg Campaign, on June 23, 1863, he was promoted to lieutenant colonel. On July 2, the second day of the battle of Gettysburg, McGilvery discovered a wide and undefended gap in the Union line along the southern end of Cemetery Ridge, north of Little Round Top. McGilvery patched together a line of artillery from various commands to fill the gap. Initially without infantry support, McGilvery's "Plum Run line" of fieldpieces was instrumental in halting the final Confederate advance toward the Union center. On July 3, the lengthy artillery line assisted in the repulse of Pickett's Charge, and in particular stopped the supporting attack of Confederate brigades under Cadmus Wilcox and David Lang.
Promoted to colonel in September 1863, he continued to command his Artillery Reserve brigade until May 1864. He replaced Robert O. Tyler in command of the army's reserve artillery and its ammunition train. He served with distinction in this role during the Overland Campaign and the Siege of Petersburg. On August 9, 1864, he was promoted to Chief of Artillery for the X Corps, commanding fifteen batteries. Only a week later, at the Battle of Deep Bottom, he was slightly wounded in a finger. The wound did not heal properly, and surgeons performed an amputation, during which McGilvery died from an overdose of chloroform being used as an anesthesia. His body was returned to his native Maine and buried in the Village Cemetery in Searsport.
Memorialization
Fort McGilvery, part of the Union earthworks at Petersburg constructed later during the siege, was named in his memory. The antebellum Post #30 of the Grand Army of the Republic in Maine was also named for McGilvery. In 2001, the Maine state legislature passed an act designating the first Saturday in September as Colonel Freeman McGilvery Day.
Wilson, James Grant and Fiske, John, editors, Appleton's Cyclopedia of American Biography. Six volumes. New York: D. Appleton and Company, 1887–1889.
U.S. Army War Department, The War of the Rebellion: A Compilation of the Official Records of the Union and Confederate Armies, 70 volumes in 4 series. Washington, D.C.: United States Government Printing Office, 1880–1901.