Frederick was the eldest son of King Vladislav II of Bohemia from his first marriage with Gertrude of Babenberg, a daughter of Margrave Leopold III of Austria. His father had ruled as a Bohemian duke since 1140; in 1158 he obtained the royal title by the Hohenstaufen emperor Frederick Barbarossa, godfather and namesake of Frederick. His elevation expressed the emperor's gratitude for Vladislav's loyalty and faithful service; he thereby became the second Přemyslid king after his grandfather Vratislav II. His son Frederick ruled as a Moravian prince of Olomouc from 1164 onwards. King Vladislav's relations with the emperor deteriorated when in 1172 he abdicated in favour of Frederick, trying to implement a line of succession in accordance to the principle of agnatic seniority, but without consulting Barbarossa. While the Prague throne was claimed by Vladislav's cousins, sons of the late Duke Soběslav I, Frederick was unable to hold on to his duchy, as his tenancy was approved by neither the Bohemian diet nor the emperor. Father and son were eventually declared deposed in September 1173 by the emperor at an Imperial Diet in Hermsdorf. In agreement with the Bohemian nobility, Barbarossa offered the throne to Vladislav's cousin Oldřich. However, Oldřich declined the honour and renounced the rule over Bohemia in favour to his elder brother Soběslav II, who was sympathetic to the peasantry. While aged Vladislav II left Bohemia and retired to the Thuringian estates of his second wife Judith, Frederick had to serve at the Imperial court. Nevertheless, Soběslav II turned out antagonistic to both the Bohemian nobles and the emperor. He was reluctant to support Barbarossa on his Italian campaign against the Lombard League, where the Imperial forces suffered a major defeat in the 1176 Battle of Legnano. Moreover, Duke Soběslav campaigned the Babenberg lands of Austria in the south, whereby Duke Henry Jasomirgott, Barbarossa's uncle, was killed in an accident. While Soběslav ignored a summons to appear at the Imperial court, Frederick was able to forge an alliance with the Moravian prince Conrad III Otto of Znojmo and the Babenberg duke Leopold V of Austria. Backed by Emperor Barbarossa, they marched against Prague where Frederick was elected duke in 1178. First attacked and defeated by Soběslav's forces at the Battle of Loděnice, he finally prevailed in a decisive victory outside the Prague city walls, in the area of present-day Nové Město, on 27 January 1179. Soběslav was removed and died in exile the following year. The emperor now recognised Frederick as an Imperial prince. The duke confirmed the drawing of the Bohemian-Austrian border and also maintained peace with his Polish, Meissen and Hungarian neighbours. In 1184 he came to Mainz to join the Diet of Pentecost with a huge retinue to attend the knightly accolade of the emperor's sons Henry VI and Frederick of Swabia. However, his reign remained overshadowed by the internal struggles of the Přemyslid dynasty: when he tried to assert the rule of his younger half-brother Ottokar over Moravia, his former ally Prince Conrad of Znojmo turned against him and temporarily drove him out of Prague. Though re-instated by Barbarossa in 1182, Frederick had to face the elevation of Moravia to an Imperial margraviate under Conrad's rule. The emperor also raised the Prague bishop, Frederick's Přemyslid cousin Henry Bretislaus, to princely status, and thus divided the Bohemian lands into three parts all dependent on him. After years of wrangling, Duke Frederick, weakened by the internal struggles, was practically a puppet of the emperor. When Margrave Conrad was defeated by the forces of Frederick's half brother Ottokar in a bloody battle at Loděnice, the Bohemian and Moravian Přemyslids finally met at Knín in 1186. To settle the dispute, Conrad acknowledged Frederick's overlordship, while the duke confirmed Conrad's rights and his succession to the Bohemian throne. Frederick died in 1189, while he prepared to follow the emperor on the Third Crusade. According to the Knín agreement, he was succeeded by Conrad who once again united Bohemia and Moravia under his rule.