The Visigoth village, one of the factions of the Germanic Goth tribe, was discovered near today's city. The first settlement was built in the years 852 - 886 by order of the emir of Cordoba, Muhammad I. It was a citadel built on the steep left bank of the Manzanares River. The city remained under the influence of the Moors until 1085, when it was conquered by King Alfonso VI of León and Castile.