Over several campaigns in the mid-10th century, the German ruler Otto I conquered northern Italy; Pope John XII crowned him emperor (the first so crowned in more than forty years) and the two of them ratified the Diploma Ottonianum, by which the emperor became the guarantor of the independence of the Papal States. Yet over the next two centuries, popes and emperors squabbled over a variety of issues, and the German rulers routinely treated the Papal States as part of their realms on those occasions when they projected power into Italy. As the Gregorian Reform worked to free the administration of the church from imperial interference, the independence of the Papal States increased in importance. After the extinction of the Hohenstaufen dynasty, the German emperors rarely interfered in Italian affairs. In response to the struggle between the Guelphs and Ghibellines, the Treaty of Venice made official the independence of Papal States from the Holy Roman Empire in 1177. By 1300, the Papal States, along with the rest of the Italian principalities, were effectively independent.