McKinley was promoted first lieutenant in February 1864, and for his services at Winchester was promoted captain on the 25th of July 1864.
He entered his father's company as a cadet about 1794, and became an ensign (or second lieutenant) in 1799 and first lieutenant in the same year.
In September 1845 he went with his regiment to join the forces of General Taylor in Mexico; there he took part in the battles of Palo Alto, Resaca de la Palma and Monterey, and, after his transfer to General Scott's army, which he joined in March 1847, served at Vera Cruz, Cerro Gordo, Churubusco, Molino del Rey and at the storming of Chapultepec. He was breveted first lieutenant for gallantry at Molino del Rey and captain for gallantry at Chapultepec. In August 1848, after the close of the war, he married Julia T.
After the Mexican war he served in the West, in Florida and elsewhere; was married in 1850 to Miss Almira Russell of St Louis; became first lieutenant in 1853, and assistant-quartermaster with the rank of captain in 1855.