A German invasion of Hungary took place in August–September 1063, interfering in a dynastic conflict in the Kingdom of Hungary. Solomon, assisted by his brother-in-law Henry IV of Germany, decided to return to Hungary in order to his restoration to the Hungarian throne against his usurper uncle Béla I. Prior to that, Henry IV refused Béla's proposals to conclude a peace treaty with the Holy Roman Empire. German troops invaded Hungary in August 1063. Béla died in an accident unexpectedly and the German army entered Székesfehérvár. Henry installed Solomon on the throne.
Background
After spending fifteen years in exile, Andrew I ascended the Hungarian throne during an extensive pagan revolt in 1046, defeating Peter Orseolo, a vassal of King Henry III of Germany. Andrew soon broke with his pagan supporters, restored Christianity and declared pagan rites illegal. He requested his younger brother Béla to return to Hungary in 1048, granting him one-third of the kingdom, with the title of duke. The two brothers closely collaborated in the subsequent years, successfully preventing the raids and invasions of the Holy Roman Empire along the western border in the early 1050s.
Andrew's son Solomon was born in 1053. The two brothers' good relationship deteriorated after King Andrew had the child Solomon crowned king in 1057 or 1058. The coronation was the consequence of the peace negotiations with the Holy Roman Empire, because the Germans did not acquiesce in a marriage between Solomon and Judith – sister of the minor Henry IV – until Solomon's right to succeed his father was declared and publicly confirmed. According to the Annales Altahenses, Béla and his eldest son Géza were absent from that meeting in September 1058, where Judith was engaged to Solomon. Thereafter Andrew I was determined to secure the throne for his son. The Illuminated Chronicle narrates that Andrew invited Béla to his manor in Várkony, where the King offered his brother a seemingly free choice between a crown and a sword (which were the symbols of the royal and ducal power, respectively). However, he had ordered that Béla be murdered if he chose the crown. Having been informed of his brother's secret plan by one of his own partisans in the royal court, Béla opted for the sword. Several historians argued the text regarding the meeting at Várkony originated in the 12th century, as kind of a retrospective justification for Béla's violent usurpation of the throne. Béla soon departed for Poland along with his partisans; he sought the assistance of Duke Boleslaus the Bold and returned with Polish reinforcements. Béla emerged the victor in the ensuing civil war, during which Andrew was mortally injured in a battle in the autumn of 1060. Béla I was crowned king on 6 December 1060, while the child Solomon and his mother fled to the Holy Roman Empire and settled in the fort of Melk. In early 1061, Anastasia traveled to Regensburg and sought assistance from Henry IV and his German court in order to recover the Hungarian throne for his minor son.
Béla I attempted to conclude a peace treaty with the Holy Roman Empire. For this purpose, shortly after his coronation, he released all German commanders – for instance, William, Margrave of Meissen – who had assisted Andrew during the civil war. However, the young German monarch's advisors refused Béla's proposals. The usurper could keep his throne for three years only because the attention of the imperial councilors under the regency of dowager queen Agnes of Poitou was drawn to the events of Italian foreign policy (the election reform of Pope Nicholas II). At the turn of 1062 and 1063, prelates Anno of Cologne then Adalbert of Bremen took over the office of regent. In the summer of 1063, an assembly of the German princes in Mainz decided to launch a military expedition against Hungary to install the young Solomon to the throne. The Annales Altahenses narrates that Béla even offered his son and heir Géza as hostage to the Germans when he was informed of the planned invasion.