A midshipman in 1815, Buchanan served until 1845, when he submitted a plan for organizing a national naval academy at Annapolis. When the academy was founded in the same year, he was appointed to head it. In 1847–48 he saw active service in the Mexican War, and in 1852–54 he accompanied Commo. Matthew C. Perry’s expedition to Japan.
In April 1861, on the eve of the Civil War, Buchanan resigned his commission, believing that Maryland would secede from the Union. He tried to recall his resignation but was dismissed the following month and entered the Confederate Navy. He commanded the ironclad ram Virginia (Merrimack) when it sank the Union frigates Cumberland and Congress in Hampton Roads (March 1862). Promoted to the rank of admiral in August, he served as senior officer thereafter. In Mobile Bay (August 1864) he fought Union ships with the ram Tennessee after other vessels of his own squadron were disabled or captured.