In September and October 1864, as deputy commander of the St. Louis district under William Rosecrans, Ewing played a major part in thwarting Sterling Price's invasion of Missouri by commanding a successful defense at Fort Davidson at Pilot Knob, Missouri. His command of 1500 heavily outnumbered soldiers (900 effectives) and a few black civilians fought off repeated attacks from a force of about 15,000 Confederates, buying additional time for the Union army to strengthen the defenses around St. Louis. Instead of surrendering, Ewing and his men successfully eluded Price's force during the night and fought a fighting withdrawal to Rolla, Missouri. On February 23, 1865, Ewing resigned to return to civilian life, tendering his resignation directly to his good friend, the President, a month before Lincoln's assassination. On February 24, 1866, President Andrew Johnson nominated Ewing for appointment to the brevet rank of major general of volunteers to rank from March 13, 1865 and the U.S. Senate confirmed the nomination on May 4, 1866.