The first admirals in English had nothing to do with ships. Around 1200, an amiral or admirail was a Saracen commander or chieftain.
The root is the Arabic amir, "commander," the same word English later borrowed directly as emir. Arabic built titles from it, such as amir al-bahr, "commander of the sea." Merriam-Webster traces admiral to that kind of phrase, so that the "al" would be the Arabic for "the."
Not every dictionary agrees on that detail. Wiktionary argues that linking the ending to the Arabic article is a folk etymology. It suggests the "-al" is more likely the ordinary Latin suffix -alis, added to amir. Either way, the core of the word is Arabic for "commander."
The move from land to sea seems to have happened in Sicily. In the 12th century the island was ruled by Normans, and King Roger II gave George of Antioch, a Greek Christian in his service, the Arabic-style title "amir of amirs." Merriam-Webster and Etymonline both place the fleet-commander sense there, in Medieval Latin forms like amiratus. By the late 1200s Anglo-French documents mention an amiral de la mer, a commander of a fleet. English used the word for its highest-ranking naval officer from the early 1400s.
Then there is the stray letter. Old French had amiral, with no d. Etymonline calls the d "probably unetymological," likely added under the influence of Latin admirabilis, "admirable." Merriam-Webster points to the Latin verb for "to admire."
Other languages made their own mix-ups. Etymonline notes that Italian almiraglio and Spanish almirante probably picked up their "al-" through confusion with Arabic words that begin with the article.
Today the title has spread to vice admirals, rear admirals and fleet admirals. Since at least 1720 it has even named a group of brightly colored butterflies, such as the red admiral.