Cologne's first Christian bishop was Maternus. He was responsible for the construction of the first cathedral, a square building erected early in the 4th century. In 794, Hildebald (or Hildebold) was the first Bishop of Cologne to be appointed archbishop. Bruno I (925–965), younger brother of Otto I, Holy Roman Emperor, founded several monasteries here.
The dynasty of the Ezzonids, later Counts of Berg, counted 7 archbishops during that period and consolidated the powers of the archbishopric over imperial affairs. The archbishops of Cologne became very influential as advisers to the Saxon, Salian and Hohenstaufen dynasties. From 1031 they also held the office of Arch-Chancellor of Italy. Their authority culminated[clarification needed] under Archbishop Engelbert II of Berg, imperial administrator (Reichsprovisor) and tutor to the emperor's son. Between 1216 and 1225, Engelbert fought for the establishment and security of the archdiocese of Cologne both as an ecclesiastical authority and as a secular territory. This led to his murder in 1225.
Construction of the Gothic cathedral started in 1248 under Konrad von Hochstaden. The eastern arm was completed and consecrated in 1322. Construction of the western arm was halted in 1475, and it would remain unfinished until 1880.
In 1074 the commune was formed. By the 13th century, the relationship between the city and its archbishop had become difficult, and after the Battle of Worringen in 1288, the forces of Brabant and the citizenry of Cologne captured Archbishop Siegfried of Westerburg (1274–97), resulting in almost complete freedom for the city. To regain his liberty the archbishop recognized the political independence of Cologne but reserved certain rights, notably the administration of justice.
Cologne effectively became a free city after 1288, and in 1475 it was formally made a free imperial city, a status that it held until annexed by France on May 28, 1796. The Archbishopric of Cologne was a state in its own right within the Holy Roman Empire, but the city was independent, and the archbishops were usually not allowed to enter it. Instead, they took up residence in Bonn and later in Brühl until they returned in 1821. From 1583 to 1761, all ruling archbishops came from the Wittelsbach dynasty. As powerful electors, the archbishops repeatedly challenged Cologne's free status during the 17th and 18th centuries, resulting in complicated legal affairs, which were handled by diplomatic means, usually to the advantage of the city.