His wife Hedwig's mother Barbara Zápolya was a sister of John Zápolya, who had claimed the vacant throne of Hungary after King Louis II was killed in battle against the Ottoman Empire in 1526. However, Joachim supported Ferdinand of Habsburg, who also claimed the crown and challenged the Turkish invaders. In 1542 Joachim assisted Ferdinand against the Ottomans at the Siege of Buda (1541). He commanded an army of Austrian, Hungarian, German, Bohemian, Italian, and Dalmatian troops, but the Elector was not a seasoned warrior and eventually beat a retreat. He was defeated again by the Ottomans in the Siege of Pest in 1542.