Named after his grandfather King Ottokar I, he was originally educated for the role of an ecclesiastical administrator, while his elder brother Vladislaus was designated heir of the Bohemian kingdom. He was possibly educated by the Bohemian chancellor Philip of Spanheim, who would later become a rival for the rule in the Duchy of Carinthia.

When his brother Vladislaus died in 1247, Ottokar suddenly became the heir to the Bohemian throne. According to popular oral tradition, he was profoundly shocked by his brother's death and did not involve himself in politics, becoming focused on hunting and drinking. As new heir, his father appointed him Margrave of Moravia and Ottokar took his residence in Brno, where he was occupied with the reconstruction of the Moravian lands devastated by Mongol raids.

In 1248 he was enticed by discontented nobles to lead a rebellion against his father King Wenceslaus. During this rebellion he was elected "the younger King" (mladší král) on 31 July 1248 and temporarily expelled his father from Prague Castle. Ottokar II held the title of King of Bohemia until November 1249.[1] However, he was excommunicated by Pope Innocent IV, whereafter Wenceslaus finally managed to defeat the rebels and imprisoned his son at Přimda Castle.[2]

Father and son were eventually reconciled to assist the king's aim of acquiring the neighbouring Duchy of Austria, where the last Babenberg duke Frederick II had been killed in the 1246 Battle of the Leitha River. King Wenceslaus had initially attempted to acquire Austria by marrying his heir, Vladislav, to the last duke's niece Gertrude of Babenberg. That match had been cut short by Vladislav's death and Gertrude's remarriage to the Zähringen margrave Herman VI of Baden. The latter was rejected by the Austrian nobility and could not establish his rule. Wenceslaus used this as pretext to invade Austria when Herman died in 1250 — according to some sources, the estates called upon him in to restore order.

Wenceslaus released Ottokar very soon and in 1251 again made him Margrave of Moravia and installed him, with the approval of the Austrian nobles, as governor of Austria. The same year Ottokar entered Austria, where the estates acclaimed him as Duke. To legitimize his position, Ottokar married the late Duke Frederick II's sister Margaret of Babenberg, who was his senior by 30 years and the widow of the Hohenstaufen king Henry (VII) of Germany (who, ironically, had been engaged to Ottokar's aunt Saint Agnes of Bohemia prior to marrying Margaret). Their marriage took place on 11 February 1252 at Hainburg.[1][3]

In 1253, King Wenceslaus died and Ottokar succeeded his father as King of Bohemia. After the death of the German King Konrad IV in 1254 while his son Conradin was still a minor, Ottokar also hoped to obtain the Imperial dignity - as King of the Romans - for himself. However, his election bid was unsuccessful and Count William II of Holland, German antiking since 1247, was generally recognised.

Feeling threatened by Ottokar's growing regional power beyond the Leitha River, his cousin King Béla IV of Hungary challenged the young king. Béla formed a loose alliance with the Wittelsbach duke Otto II of Bavaria and tried to install his son Stephen as Duke of Styria, which since 1192 was ruled in personal union with Austria according to the Georgenberg Pact. The conflict was quelled through papal mediation: it was agreed that Ottokar was to yield large parts of Styria to Béla in exchange for recognition of his right to the remainder of Austria.

However, after a few years the conflict resumed and Ottokar defeated the Hungarians in July 1260 at the Battle of Kressenbrunn, ending years of disputes over Styria with Béla IV. Béla now ceded Styria back to Ottokar, and his claim to those territories was formally recognized by Richard of Cornwall, then king of Germany and nominal ruler of all German lands. This peace agreement was also sealed by a royal marriage. Ottokar ended his marriage to Margaret and married Béla's young granddaughter Kunigunda of Halych, who became the mother of his children. The youngest of them became his only legitimate son, Wenceslaus II.

During the Imperial interregnum, Ottokar could increase his personal influence in the throne quarrel between Richard of Cornwall and Alfonso of Castile. In 1266 he occupied the Egerland, and in 1268 he signed an inheritance treaty with the Sponheim duke Ulrich III of Carinthia, succeeding him in Carinthia, Carniola and the Windic March the next year. In 1272 he also acquired Friuli. His rule was once again contested by the Hungarians on the field of battle. After another victory, Ottokar became the most powerful king within the Empire.

After Richard of Cornwall had died in April 1272 and the claims raised by Alfonso of Castile were denied by Pope Gregory X, a new election for the Imperial German throne took place in 1273. However, the Bohemian king was again not the successful candidate, as the electors voted for the "little count" Rudolf of Habsburg, Ottokar's last and finally victorious rival.

Ottokar refused to acknowledge Rudolf's election, and urged the Pope to adopt a similar policy. At a convention of the Imperial Diet at Nuremberg in 1274, Rudolf decreed that all Imperial lands that had changed hands since the death of the last Hohenstaufen emperor Frederick II must be returned to the crown. This would have deprived Ottokar not only of the Egerland, but also of the Austrian, Styrian, and Carinthian duchies. In 1275 Rudolf placed Ottokar under the Imperial ban and besieged his Hofburg residence in Vienna, while the Bohemian lands were shaken by a rebellion led by the Vítkovci noble Zavis of Falkenstein. This compelled Ottokar in November 1276 to sign a new treaty by which he gave up all claims to Austria and the neighboring duchies, retaining for himself only Bohemia and Moravia. Ottokar's son Wenceslaus was also betrothed to Rudolf's daughter Judith. It was an uneasy peace.

Two years later, the Bohemian king made a last attempt to recover his lost lands by force. Ottokar again found allies in Bavaria, Brandenburg and Poland. He collected a large army to meet the forces of Rudolf and his ally King Ladislaus IV of Hungary in the Battle on the Marchfeld on 26 August 1278, where he was defeated and killed, possibly by his own liensmen. Rudolf had his body laid out in state at the Vienna Minorites Church. In 1297 Ottokar's mortal remains were finally transferred to St. Vitus Cathedral in Prague. His minor son Wenceslaus II succeeded him as King of Bohemia.

On 11 February 1252, Ottokar married Margaret of Austria. Margaret was 26 years older than him and the couple's childless marriage ended with an annulment.[3] On 25 October 1261, Ottokar married Kunigunda of Slavonia. They probably had four children:[4]

Ottokar also had two extramarital sons and daughters. The most important was his firstborn, Nicholas. He was never accepted as heir apparent to the Bohemian crown by the sitting pope, but was given the Duchy of Opava as fief in 1269. Other illegitimate children include John, provost of Vyšehrad Chapter.

Ottokar is considered one of the greatest kings of Bohemia, along with Charles IV. He was a founder of many new towns (about 30 — not only in Bohemia, Moravia and Silesia, but also in Austria and Styria) and incorporated many existing settlements through civic charters, giving them new privileges. He was a strong proponent of trade, law and order. Furthermore, he instituted open immigration policies through which skilled German-speaking immigrants settled in major cities throughout his domains. As noted, the historic East Prussian city of Königsberg (King's Mountain) was named in his honor as a tribute to his support of the Teutonic Knights in their war with the pagan Old Prussians.

As Czech traditional law was different from that of his other domains, many principles introduced during his reign formed core of the Czech law for the following centuries. From his time stems the oldest preserved source of Czech law, Zemské desky, and also the oldest written Czech communal law, recorded in the founding deeds of the respective towns. By supporting the city of Jihlava (German: Iglau) with its mines, he laid foundation of the silver wealth of later Bohemian kings. Privileges of civic charters usually excluded the towns from obedience to the traditional courts held by members of nobility. This can be seen as a step towards equality and a precursor of modern civil law.

In the country, Ottokar's introduction of the Law of Emphyteusis into the Czech law is sometimes interpreted as "Germanization". In fact it was progressive, for it freed subjects from feudal obligations, except for rent — and tax, if such was levied. Free selling and leaving of estates could also be bought and soon became common. Thus, Ottokar can be reckoned an early Bohemian ruler who furthered legal equality in Medieval times. This change of legal environment in Bohemia was introduced by systematic founding of villages chartered under this law.

He issued also a general privilege to the Jews (1254), which established principles of integration of the Jews into the Czech society until 1848. The Jews were now eligible for various positions, such as servants of crown, thereby being somewhat less subject to discrimination. Instead of being able to claim only the support of individual lords, the Jews could from then on claim support of any royal officer.

Ottokar followed with a systematic policy of strengthening his domains by building fortifications. Besides supporting towns, he built many fortresses himself — Zvíkov Castle, Křivoklát Castle or Bezděz Castle in Bohemia, and the famed Hofburg Palace in Vienna — and also induced his vassals to build castles. A sign of rising strength of Bohemia, it was also a reaction to the Mongol raids of the 13th century (see Béla IV of Hungary). Conflict for the title of ownership to these fortified places built by members of nobility was probably the source of an uprising in 1276, which cost Ottokar the Austrian lands, and two years later (in an attempt for reconquest) his life.

Some of the fortresses built by Ottokar were for centuries the strongest in Bohemia. Ironically, Bezděz Castle served as a prison for his son Wenceslaus II of Bohemia for short time after Ottokar's death. The castle housed Bohemian legal records Zemské desky and many spiritual and temporal treasures during the destructive civil strife of the Hussite wars (1419–1434) in Bohemia. It was conquered in 1620, during the 30 Years' War, but by then it was long deserted, and in that state was defended by rebelling subjects against an Imperial army.

Ottokar is a significant figure in history and legend. In the Divine Comedy by Dante, Ottokar is seen outside the gates of Purgatory, in amiable companionship with his imperial rival Rudolf. He is also the protagonist of a tragedy by the 19th-century Austrian playwright Franz Grillparzer, titled König Ottokars Glück und Ende.

In the painting,Přemysl Otakar II: The Union of Slavic Dynasties, part of Alfons Mucha's 20-canvas work The Slav Epic, Ottokar is depicted at his niece's wedding celebration, forging alliances with other Slavic rulers in attendance.

King Ottokar probably served as inspiration for Herges' King Ottokar's Sceptre. In the Adventures of Tintin, Ottokar is a legendary King of the fictitious realm of Syldavia, geographically overlapping, loosely, some southern parts of the real Ottokar II's Kingdom.