مجريطMajrīṭ (AFI [madʒriːtˁ]) is the first documented reference to the city. It is recorded in Andalusi Arabic during the al-Andalus period. The name Magerit ([madʒeˈɾit]) was retained in Medieval Spanish. The most ancient recorded name of the city "Magerit" (for *Materit or *Mageterit?) comes from the name of a fortress built on the Manzanares River in the 9th century AD, and means "Place of abundant water" in Arabic. A wider number of theories have been formulated on possible earlier origins.
According to legend, Madrid was founded by Ocno Bianor (son of King Tyrrhenius of Tuscany and Mantua) and was named "Metragirta" or "Mantua Carpetana". Others contend that the original name of the city was "Ursaria" ("land of bears" in Latin), because of the many bears that were to be found in the nearby forests, which, together with the strawberry tree (Spanish madroño), have been the emblem of the city since the Middle Ages.
Nevertheless, it is also speculated that the origin of the current name of the city comes from the 2nd century BC. The Roman Empire established a settlement on the banks of the Manzanares river. The name of this first village was "Matrice" (a reference to the river that crossed the settlement). Following the invasions carried out by the Germanic Sueves and Vandals, as well as the Sarmatic Alans during the 5th century AD, the Roman Empire no longer had the military presence required to defend its territories on the Iberian Peninsula, and as a consequence, these territories were soon occupied by the Vandals, who were in turn dispelled by the Visigoths, who then ruled Hispania in the name of the Roman emperor, also taking control of "Matrice". In the 8th century, the Islamic conquest of the Iberian Peninsula saw the name changed to "Mayrit", from the Arabic term ميراMayra (referencing water as a 'tree' or 'giver of life') and the Ibero-Roman suffix it that means 'place'. The modern "Madrid" evolved from the Mozarabic "Matrit", which is still in the Madrilenian gentilic.