Frederick II (26 December 1194 - 13 December 1250; Sicilian: Fidiricu, Italian: Federico, German: Friedrich) was King of Sicily from 1198, King of Germany from 1212, King of Italy and Holy Roman Emperor from 1220 and King of Jerusalem from 1225. His mother Constance was Queen of Sicily and his father was Henry VI of the Hohenstaufen dynasty. Frederick's reign saw the Holy Roman Empire reaching its all time territorial peak.

A new pope, Innocent IV, was elected on 25 June 1243. He was a member of a noble Imperial family and had some relatives in Frederick's camp, so the Emperor was initially happy with his election. Innocent, however, was to become his fiercest enemy. Negotiations began in the summer of 1243, but the situation changed as Viterbo rebelled, instigated by the intriguing local cardinal Ranieri Capocci. Frederick could not afford to lose his main stronghold near Rome, so he besieged the city. Innocent convinced the rebels to sign a peace but, after Frederick withdrew his garrison, Ranieri nonetheless had them slaughtered on 13 November. Frederick was enraged. The new Pope was a master diplomat, and Frederick signed a peace treaty, which was soon broken. Innocent showed his true Guelph face, and, together with most of the Cardinals, fled via Genoese galleys to Liguria, arriving on 7 July. His aim was to reach Lyon, where a new council was being held since 24 June 1245. Despite initially appearing that the council could end with a compromise, the intervention of Ranieri, who had a series of insulting pamphlets published against Frederick (in which, among other things, he defined the emperor as a heretic and an Antichrist), led the prelates towards a less accommodating solution. One month later, Innocent IV declared Frederick to be deposed as emperor, characterising him as a "friend of Babylon's sultan," "of Saracen customs," "provided with a harem guarded by eunuchs," like the schismatic emperor of Byzantium, and in sum a "heretic."  The Pope backed Heinrich Raspe, landgrave of Thuringia, as rival for the imperial crown and set in motion a plot to kill Frederick and Enzo, with the support of the pope's brother-in-law Orlando de Rossi, another friend of Frederick. The plotters were unmasked by the count of Caserta, however, and the city of Altavilla, where they had found shelter, was razed. The guilty were blinded, mutilated, and burnt alive or hanged. An attempt to invade the Kingdom of Sicily, under the command of Ranieri, was halted at Spello by Marino of Eboli, Imperial vicar of Spoleto.  Innocent also sent a flow of money to Germany to cut off Frederick's power at its source. The archbishops of Cologne and Mainz also declared Frederick deposed, and in May 1246 Heinrich Raspe was chosen as the new king. On 5 August 1246 Heinrich, thanks to the Pope's money, managed to defeat an army of Conrad, son of Frederick, near Frankfurt. Frederick strengthened his position in Southern Germany, however, acquiring the Duchy of Austria, whose duke had died without heirs. A year later Heinrich died, and the new anti-king was William II, Count of Holland.  Between February and March 1247 Frederick settled the situation in Italy by means of the diet of Terni, naming his relatives or friends as vicars of the various lands. He married his son Manfred to the daughter of Amedeo di Savoia and secured the submission of the marquis of Monferrato. On his part, Innocent asked protection from the King of France, Louis IX, but the king was a friend of the Emperor and believed in his desire for peace. A papal army under the command of Ottaviano degli Ubaldini never reached Lombardy, and the Emperor, accompanied by a massive army, held the next diet in Turin.

Answer the following question by taking a quote from the article: Who prevailed?
Frederick settled the situation in Italy by means of the diet of Terni, naming his relatives or friends as vicars of the various lands.