# Ivan Kőszegi

Ivan Kőszegi (Hungarian: Kőszegi Iván, German: Yban von Güns; died 5 April 1308) was an influential lord in the Kingdom of Hungary at the turn of the 13th and 14th centuries. Earlier historiographical works also refer to him Ivan Németújvári (Hungarian: Németújvári Iván, German: Ivan von Güssing, Croatian: Ivan Gisingovac). He was Palatine in 1281, between 1287 and 1288, and from 1302 until 1307, Ban of Slavonia in 1275, from 1284 until 1285 and in 1290, and Master of the treasury in 1276 and 1291.
Originating from the powerful Kőszegi family, his career was characterized by series of rebellions and violations of the law against the royal power. As one of the so-called oligarchs, he established a province in Western Transdanubia, which laid in the borderlands of Hungary with Austria, and ruled Győr, Sopron, Moson, Vas and Zala counties de facto independently of the monarchs by the 1280s. Beside his rebellions in Hungary, he waged wars with the Duchy of Austria too. Because of his plundering and looting raids against the Styrian provinces, he was dubbed as "greedy wolf" by the Austrian chronicles. During the era of feudal anarchy, he usually played a role of "kingmaker". For instance, he invited Andrew the Venetian to the throne against the reigning Ladislaus IV of Hungary three times (1278, 1287, 1290). He initially supported Andrew III after his accession to the throne, but from 1292 he turned against the king and became a partisan of the pretender, Charles Martel, Duke of Salerno. After the extinction of the Árpád dynasty in 1301, he betrayed the House of Anjou too and played an important role in the subsequent succession war as the partisan of Wenceslaus, then Otto.

## Family

Ivan (also John) was born in the 1240s into the wealthy and influential Kőszegi family, originating from the gens (clan) Héder, as one of the four sons of the powerful lord Henry I Kőszegi. His brothers were Nicholas I, Henry II – who were also elevated into high dignities during the age of the late Árpáds – and Peter, the Bishop of Veszprém from 1275 till his murder in 1289.
His marriage to an unidentified noblewoman produced three children. His eldest son was Gregory, who held some minor offices before predeceasing him in 1297. He left two sons, Nicholas III and Andrew, who inherited Ivan's wealth and dominion in 1308. Ivan also had an unnamed daughter, who married a certain Dominic, a familiaris of her father. This Dominic fought in the Battle of Göllheim in 1298. Some historians identified him with Dominic Csák. During his advanced age, Ivan's younger son John the "Wolf" was born in the 1300s; after his downfall in Hungary, he integrated into the Austrian nobility, becoming ancestor of the Bernstein (or Pernstein) family. Ivan also had an illegitimate son, Nicholas, who was born in 1282 from an extramarital affair. Nicholas served as Bishop of Győr from 1308 to 1336.

## Early career

Ivan Kőszegi first appeared in contemporary records in March 1265, when he participated in the Battle of Isaszeg alongside his father Henry and brother Nicholas. During the civil war between Béla IV of Hungary and his son Duke Stephen, Ivan's father was a staunch supporter of the king and led the royal army against the duke. However Stephen gained a decisive victory over his father's army, and Henry Kőszegi and his two sons were captured. His defeater Pousa Tengerdi presented the fettered prisoner Ivan Kőszegi in the ducal court of Stephen following the clash. The Kőszegis were being held as prisoners and after the Battle of Isaszeg, Béla IV was forced to accept the authority of Stephen in the eastern parts of the kingdom. On 23 March 1266, father and son confirmed the peace in the Convent of the Blessed Virgin on 'Rabbits' Island and Henry and his two sons, alongside others, were released from captivity.
Stephen V ascended the Hungarian throne in May 1270, following his father's death. In response, the king's sister Anna seized the royal treasury and fled to Bohemia. Several magnates and Béla's closest advisors followed her and left Hungary, including Henry Kőszegi, who handed over Kőszeg, Borostyánkő (Bernstein, Austria) and other castles along the western borders to Ottokar II. In the same time, Ivan Kőszegi also handed over his "two castles called Sztrigó" (today Štrigova, Croatia), which laid in Zala County, to the Bohamian king. Henry and his sons had spent the next two years in exile at Ottokar's court in Prague. Their departure caused a war between Hungary and Bohemia, which lasted until the conclusion of an agreement in Pressburg in July 1271. According to their treaty, Stephen V promised that he would not assist Ottokar's opponents in Carinthia, and Ottokar II renounced the castles he and his partisans held in Hungary. The royal armies soon recaptured Kőszeg, Borostyánkő and other fortresses along the western border of Hungary. Ivan Kőszegi was knighted by Ottokar during his exile, according to the Steirische Reimchronik.
Henry Kőszegi and his sons returned from Bohemia to Hungary following Stephen's death in the summer of 1272. His ten-year-old son Ladislaus IV ascended the throne. During his minority, many groupings of barons fought against each other for supreme power. The arriving Henry Kőszegi brutally murdered Ladislaus' cousin, Béla of Macsó, the only adult male member of the Árpád dynasty. The Kőszegis entered alliance with the Gutkeleds and the Geregyes, forming one of the two main baronial groups (the other one was dominated by the Csák and Monoszló clans). Ivan's father became a key figure in the early stage of the era of so-called feudal anarchy. When Henry extended his dominance in the royal council, Ivan served as ispán of Zala County – where his initial lands mostly laid – from September 1272 to March 1273 (with a short interruption in November 1272). In this capacity, he participated in private initiative Hungarian incursions into Austria and Moravia, Ottokar's realms in February 1273, along with Matthew Csák, Denis Péc, Joachim and Amadeus Gutkeled. Ivan was involved in the skirmishes against Styria and Carinthia. After the siege of Fürstenfeld, Matthew Csák turned against Carinthia, while Ivan commanded his troops into Styria. His army besieged Waltersdorf and Scenleurench. Thereafter, Ivan functioned as ispán of Sopron County between June 1273 and September 1274. In retaliation for Hungarian incursions, Ottokar's troops invaded the borderlands of Hungary in April 1273. They captured Győr and Szombathely, plundering the western counties. The royal council sent Joachim Gutkeled and Ivan Kőszegi to recapture the castle of Győr. Kőszegi also participated in the battle at Laa in August. However Ottokar II launched a successful retaliatory strike in the autumn of 1273, and seized many fortresses again, including Győr and Sopron. Ivan and Nicholas Kőszegi led a small-size army, which crossed the river Morava and attacked a Bohemian unit at Marchegg. They also unsuccessfully besieged the castle there. As ispán of Sopron County, Ivan organized the line of defense against the invading forces. He commanded a royal relief army, which assisted to defend the castle of Kobersdorf (Kabold). Ivan, who, in order to gain time, offered a duel with a third of himself against three knights including Henry, Count of Pfannberg, successfully defended Kapuvár (German: Valbach) by destroying the dam at the river Vág (Váh) and flooding the surrounding area. Thereafter he fought in Pereszteg and Lós, harassing the invading Bohemian army with hit-and-run tactics. He unsuccessfully tried to recapture Sopron from the Bohemian troops. Ivan was also present at the siege of Győr.
Ivan lost influence for a brief time after the Battle of Föveny in late September 1274, when Peter Csák defeated the united forces of the Kőszegis and the Gutkeleds. Henry Kőszegi was killed, but his sons Nicholas and Ivan managed to flee the battlefield, withdrawing their troops to the borderlands between Hungary and Austria. Thereafter Peter Csák and the young Ladislaus IV gathered an army against the Kőszegis' domain in the autumn of 1274; their troops marched into Western Hungary, pillaging the brothers' landholdings. Nicholas and Ivan barricaded themselves in the castle of Szalónak (present-day Stadtschlaining, Austria). The royal army besieged the fort, but failed to capture it because of the coming winter. Through his ambitious and unscrupulous sons, the Kőszegi family survived their paterfamilias' death.

## Powerful baron
### Rebellions against Ladislaus IV

Despite their violent actions against the monarch, the Kőszegis regained their influence and retook the power by the spring of 1275, when Nicholas became Palatine, and Ivan was made Ban of Slavonia, at first jointly with Nicholas Gutkeled, later solely. In this capacity, Kőszegi was responsible for the territory between the river Drava and the Kapela Mountains, while Gutkeled administered the Adriatic Coast (the dignity of Ban of Croatia emerged from that time in the Kingdom of Hungary). Ivan Kőszegi lost his dignity by the autumn of 1275, when the Csáks retook the positions in the royal council. Thereafter the Csák group launched a massive military campaign against the Kőszegi and Gutkeled dominions; while Ugrin Csák attacked Joachim Gutkeled's forces at Föveny, Peter Csák plundered and devastated the territory of the Diocese of Veszprém which headed by Bishop Peter Kőszegi, Ivan's brother. Joachim Gutkeled and the Kőszegis again removed their opponents from power at an assembly of the barons and noblemen at Buda around 21 June 1276. Ivan became Master of the treasury during that time, while Nicholas elevated into the position of Palatine of Hungary for the second time. Beside that Ivan was also ispán of Bánya (Árkibánya) ispánate, which laid in the territory of Nyitra County.
Joachim Gutkeled died while battling against the Babonići in April 1277. A month later, the general assembly declared Ladislaus IV to be of age, who was also authorized to restore internal peace with all possible means. These events ended the five-year chaotic conditions in the realm. The Kőszegis and the Babonići divided the Gutkeled's province between each other on the border of Transdanubia and Slavonia. Sometimes in the second half of the 1270s, Nicholas and Ivan handed over the family's landholdings in Varaždin County to their much younger brother Henry. In the course of the division of lands between the two elder brothers in 1279, Ivan was granted Kőszeg, Borostyánkő and Sárvár, while Szentvid and Léka (present-day Lockenhaus, Austria) went to Nicholas' property. Since then, Ivan Kőszegi began to pursue an independent policy from Nicholas, which contributed to the establishment of an oligarchic province by the end of the 13th century. Simultaneously Ladislaus IV defeated his allies, the Geregyes, Ivan attempted to play off the late Stephen V's first cousin, Andrew the Venetian, against Ladislaus. Upon his invitation, the duke came to Hungary for the first time in 1278. Andrew demanded Slavonia for himself, adopting the title of "Duke of Slavonia, Dalmatia and Croatia" and marched as far as Lake Balaton with Kőszegi's troops. Duke Andrew also made Ivan as treasurer of his ducal court. In addition, Ivan Kőszegi was styled as ispán of Zala County too from 1278 to 1279. Meanwhile, Ottokar contacted with Ivan Kőszegi through Paltram vor dem Freithof, a burgher of Vienna, and persuaded him to storm into Austria and Styria, which were the realms of Rudolf by that time. Duke Andrew achieved nothing, however, and went back to Venice in autumn, because the Hungarian royal troops played a decisive role in Rudolf's victory over Ottokar II in the Battle on the Marchfeld on 26 August, which strengthened Ladislaus' domestic political positions and resulted Ottokar's death. Ivan Kőszegi intended to participate in the battle on the side of Ottokar, but his troops only got as far as Wiener Neustadt. Following the battle, the Kőszegis experienced a significant loss of prestige, while their rival Matthew Csák was entrusted to restore public order, who dealt a serious blow to the allies of the Kőszegis in Transdanubia in this capacity. At the turn of 1278 and 1279, Ivan Kőszegi tried to reconcile with Rudolf, offering his services, but the German king rejected it citing his contract with Ladislaus IV. Rudolf informed the Hungarian king on Ivan's attempt and requested Ladislaus to persuade the rebellious baron to compensate for the damage caused in previous years for his realms and himself offered assistance in redressing common grievances. The chronicle of Matthias of Neuenburg preserved that Ivan was invited to Vienna in the midst of this endeavor, where, instead of negotiations, he was humiliated by submersion under ice ordered by Rudolf. Thereafter the Kőszegi brothers pledged allegiance to Ladislaus IV in early 1279, with the mediation of the arriving papal legate, Philip, Bishop of Fermo.
The Kőszegi brothers stayed away from the conflict between Ladislaus IV and Philip of Fermo, which emerged over the question of treatment of the pagan Cumans in Hungary. Ivan and his brothers – Nicholas and Peter – concluded peace with their local enemies, the Babonići and Frankopans in October 1280 at Ozalj Castle along the river Kupa. Taking advantage of the chaotic situation following the papal legate's arrival, Nicholas, Ivan and Henry plundered the estates of the Diocese of Zagreb at various times in the following months. As a result, Timothy, Bishop of Zagreb excommunicated them in March 1281. According to the bishop's letter to the other prelates in the realm, Ivan Kőszegi held the ispánates of Orbász (Vrbas), Szana, Garics (Podgaric) and Gecske (Gacka) in Slavonia and Croatia during the excommunication, and also usurped the Gerzence (Garešnica) lordship from the diocese. Following Philip's departure from Hungary in the autumn of 1281, Ivan Kőszegi was made Palatine of Hungary by Ladislaus IV despite his earlier crime; the young king wanted revenge on those barons who have captured him during his conflict with the papal legate. As historian Jenő Szűcs noted, this appointment marked a recurrence to the anarchic-type changes of governments, which characterized the first five regnal years of the minor Ladislaus. Ivan Kőszegi actively participated in the subsequent war against the rebellious Finta Aba in mid-1281. His troops were present at the sieges of Gede and Szalánc castles (present-day Hodejov and Slanec, Slovakia). Yet, he was soon dismissed and replaced as Palatine by Matthew Csák under unknown circumstances at turn of 1281 and 1282.
Since the early 1280s, Nicholas and Ivan Kőszegi extended their influence over Sopron County, taking advantage of that both powerful leaders of the neighboring Csák clan, Matthew II and Peter had died by 1283 or 1284. During this course, Ivan embroiled in conflict with several members of the native Osl clan in the county. At the end of 1283, Ladislaus IV laid siege to Borostyánkő, which was held by Ivan. However, he resisted, forcing the king to lift the siege in early 1284. During the royal campaign, Ivan captured Herbord II Osl and held him in captivity. Subsequently, several documents refer to Ivan's violent actions against local landowners, including the Osls in the region. According to historian Gyula Kristó, Ivan brought whole Sopron County under his jurisdiction and annexed it to his emerging oligarchic province by 1285, when several local nobles were mentioned as his familiares. The advancing Kőszegi troops gradually also displaced another local strongman Conrad Győr from the region, who had once possessed huge landholdings in Moson County. Conrad's lands laid in the boundaries of interests of the two most powerful and aggressive oligarchic provinces – Ivan Kőszegi seized his villages one after another in Moson County by the mid-1280s and handed over them to their familiares and relatives, the Héderváris, while the Csáks expelled him from Pozsony County. Ivan Kőszegi also persuaded the members of the Ják clan by threat and violence to hand over to him their inherited lands in Sopron and Vas counties through unprofitable contracts.
Following his failure, Ladislaus had to reconcile with the Kőszegi brothers in the spring of 1284. While Nicholas became again Palatine, Ivan was appointed Ban of Slavonia. He held the dignity until the next year. Ladislaus spent the last years of his life wandering from place to place, staying among his Cuman subjects. Hungary's central government lost power because the prelates and the barons ruled the kingdom independently of the monarch. Ivan Kőszegi launched an individual foreign policy at the borderlands between Austria and Hungary, establishing a de facto independent province, which threatened both realms. Contemporary Austrian chronicles – the Annales Sancti Rudperti Salisburgensis and Ottokar aus der Gaal's Steirische Reimchronik ("Styrian Rhyming Chronicle") – preserved Ivan's serious clash with Albert I, Duke of Austria in 1285. Accordingly, the Kőszegi troops invaded the neighboring Habsburg lands and marched into Wiener Neustadt, devastating the region and looting the settlements along the river Leitha. Initially, Albert tried to settle the conflict by negotiation, but the pillage of the Austrian and Styrian borderlands "has become commonplace" on Ivan's part. Therefore, the duke summoned his army from the Austria, Styria and Swabia and commissioned his councillor Hermann von Landenberg to lead his forces into Hungary in May–June 1285. The Austrians intended to besiege Borostyánkő, but Ivan asked for help from his three brothers, Nicholas, Peter and Henry, who recruited an army of 1,000 people. This was the source of uncertainty in Landenberg's army. Taking advantage of their inaction, Ivan Kőszegi and his troops (including Cumans or Pechenegs) encircled the enemy and shot their camp with arrows, while they did not undertake an open confrontation with the Austrians' heavy cavalry. Several Austrian nobles were captured during the skirmish. After that Albert made a covenant with the Kőszegis in Wiener Neustadt; in return for the release of prisoners, the duke promised he will support Ivan Kőszegi's any efforts and ambitions in the Kingdom of Hungary against all his opponents, excluding the Holy Roman Empire, which was ruled by Albert's father Rudolf. The duke also proclaimed that he took Ivan under his protection and considered the Hungarian oligarch as his subject. In response, Ivan guaranteed that he put his forces for Albert's disposal, if necessary.
Archbishop Lodomer persuaded Ladislaus to convene a general assembly in the early summer of 1286 in order to reconciliation between the king and the Kőszegi brothers. There Ladislaus provided one-year grace period to the Kőszegis and their familiares. In September 1286, the king managed a self-coup, expelling members of the Kőszegi–Borsa baronial group from the royal council. Neglecting the Kőszegis' rival, the Aba clan, Ladislaus IV appointed his own loyal soldiers and lesser nobles to the high positions. Thereafter Ladislaus IV launched his fifth and last royal campaign against the Kőszegi territory in November 1286. The king seized Kőszeg, but Ivan managed to escape. He and his brothers moved to the left bank of the Danube, they also captured Pressburg Castle for a brief time. Duke Albert took advantage of the opportunity, and marched into Hungary, where his army successfully besieged and seized Pressburg from the Kőszegis in the spring of 1287. Simultaneously, the Kőszegis' allies, the Borsa brothers – Roland and James – arrived from Transtisia; they joint troops defeated Ladislaus' army at the river Zsitva (Žitava) in March. During the conflict, Ivan again invited Duke Andrew to Hungary for a brief time sometime in the spring of 1287. After a new reconciliation, Ivan Kőszegi was appointed Palatine of Hungary, he was first mentioned in this capacity in June 1287. He was also styled as ispán of Sopron County since that year until at least 1295, but it is plausible that he bore the title until his death. As Palatine, Ivan Kőszegi summoned three "general assemblies" (generalis congregatio) for "the will of all nobles and free men with other social status of Vas County" in Szombathely in June 1288. This was the first time when a palatine convened a county assembly in his own right, neglecting the monarch's contribution. Gyula Kristó writes, Ivan summoned the assembly explicitly without the permission of Ladislaus. In the same year, Ivan Kőszegi exchanged his castle of Plošćica in Slavonia (today ruins in Ivanska, Croatia) with the Gutkeleds for their lands (Egervár) in Vas County.
Ivan Kőszegi and his brothers continuously raided the western border region of Austria and Styria. For instance, they attacked and sacked the castle of Ebenfurth in 1287–1288. Abbot Henry of Admont invaded the Kőszegi territories from the castle Radkersburg, causing serious damage. In response, Ivan summoned his army and marched to the walls of the fort, raiding the surrounding countryside and driving away the cattle grazing there, but the castle itself was not besieged. Henry recruited an army among cheese-making peasants and chased Ivan's forces, who, however, took advantage of his local knowledge of the borderland and his forces surrounded the abbot's troops in the wooded, swampy area, inflicting a heavy defeat on them in November 1287. Henry, together with Leopold, Bishop of Seckau, again attacked Ivan's territory in January 1288. The Kőszegis were involved in the conflict between Duke Albert and Rudolf of Hoheneck, the Archbishop of Salzburg over the affiliation of the Admont Abbey. The archbishop complained that his subject, abbot Henry entered the duke's service as captain-general of Styria and threatened those clergymen with excommunication, who held secular positions in the ducal court. In response, Albert confiscated the abbey and the surrounding Enns Valley from the archdiocese. Rudolf gathered his army at the end of 1288. He entered alliance with the Kőszegis and took an oath that he will support them in their efforts against Duke Albert. In accordance with the agreement, as the Steirische Reimchronik narrates, Ivan Kőszegi sent his 300 soldiers to invade Styria and plunder Radkersburg. The chronicles say Ivan looted the surrounding cities and settlements like a "greedy wolf" (Latin: lupus rapax). His attack soon resulted an escalation into a large-scale war in the borderlands between Austria and Hungary. Duke Albert launched a massive royal campaign ("Güssing Feud"; German: Güssinger Fehde) with his 15,000-size army against the Kőszegis and their familiares' castles and forts in the spring of 1289. The Austrians captured at least 30 fortresses and settlements along the western borders, including Nagymarton (Mattersburg), Németújvár (Güssing), Sopron (Ödenburg), Kabold (Kobersdorf), Szalónak (Stadtschlaining), Rohonc (Rechnitz) and Óvár (Altenburg). Ivan Kőszegi attempted to relieve Nagymarton from the siege by trying to lure the Austrian army away from their camp and near the castle wall, but failed and finally retreated. Albert later launched two additional expeditions against the Kőszegis in the remaining year; his troops captured Kőszeg (October) then Szentvid (December) too. Ivan ensured the fierce resistance of the citizens of Kőszeg by taking hostages from every family. His army annihilated a 500-member contingent of the besieging army and caused significant losses to the Carinthian troops as well. He even attempted to bribe Albert's advisors to persuade their duke to abandon the siege. Ivan managed to defend Borostyánkő only on 26 September. According to Albert's chronicles, Ivan Kőszegi ordered to mutilate his 500 Austrian prisoners of war. Despite these conquests at the expense of the Hungarian realm, Ladislaus IV did not intervene in the war, and passively supported Duke Albert.

### Andrew's ally then enemy

With the consent of Lodomer, Ivan Kőszegi offered the crown to the king's distant relative Andrew the Venetian. After twelve years, the pretender returned to Hungary at the beginning of 1290, greeted him by Ivan Kőszegi and Benedict Rád, the new Bishop of Veszprém in Zadar. Ivan's aspiration against Ladislaus IV was also supported by Wenceslaus II of Bohemia. Andrew appointed Ivan Kőszegi as Ban of Slavonia and ispán of Vas County. Before Andrew was successful, however, Ivan's local enemy Arnold Hahót captured and sent him to the court of Duke Albert in Vienna. Ladislaus IV was assassinated by his Cuman subjects in July 1290. After his release, Archbishop Lodomer crowned Andrew III king in Székesfehérvár on 23 July 1290. Although Ivan Kőszegi and Lodomer jointly invited Andrew to the Hungarian throne, their motivation was different: the oligarch wanted a new controllable and weak-handed ruler to lead the kingdom instead of the unpredictable Ladislaus, while Lodomer and his suffragans were aimed to strengthen the royal power to put an end to the political anarchy. Due to his short-term interests in order to recover his lost castles and estates, Ivan initially supported Andrew's efforts. He handed over the dignity of Ban of Slavonia to his younger brother Henry by October 1290. Ivan was referred to as Master of the treasury from February to October 1291. He also administered the Bánya ispánate beside that. As Rudolf I of Germany attempted to bestow Hungary on his own son, Duke Albert of Austria, on 31 August 1290, Andrew III also had temporary interest community with the Kőszegis. At first, Andrew restored Óvár in April 1291. After the failure of the diplomatic negotiations between the two realms, Ivan and his two brothers participated in the king's military campaign in the summer of 1291, when the Hungarian troops invaded Austria, forcing Albert to withdraw his garrisons from the towns and fortresses – including Pressburg and Sopron – that he had captured two years before, many of which were held by the Kőszegis before their conquest.
The Peace of Hainburg, which concluded the war, was signed on 26 August 1291. The peace treaty prescribed the destruction of the fortresses that Albert had seized from the Kőszegis, which was in the interests of both monarchs. The Kőszegis were outraged at Andrew's move. Ivan lost his dignity of Master of the treasury and his position in the royal council around October, while Nicholas was also replaced as Palatine. At the turn of 1291 and 1292, Ivan Kőszegi met papal legate John, Bishop of Iesi. During their negotiations, Ivan proclaimed that he will only recognize that king who is supported by the Holy See, which had definitely meant the betrayal of Andrew. After a few months of tension, the Kőszegi brothers rose up in open rebellion against Andrew in spring 1292, acknowledging the late Ladislaus' nephew, Charles Martel of Anjou, as King of Hungary. As a political gesture, his father Charles II of Naples perpetually donated Vas and Sopron counties to Ivan and his son Gregory, as fiefdoms, which element of feudalism was unaccustomed in Hungary. Since then the ispánate of Vas County was usurped by Ivan and his descendants without interruption until 1327. Simultaneously, in a letter, Charles Martel's mother Queen Mary of Naples authorized "her beloved follower" Ivan to launch a war against Andrew, "the usurper of the Hungarian throne and his accomplices". While Nicholas fought against the future oligarch, but still a courtly knight, Matthew III Csák in Pozsony County, Ivan was active in Vas and Zala counties. He besieged and occupied the fort of Buzádsziget from Andrew's faithful partisan Atyusz Hahót. The royal troops subdued the rebellion by July, but Ivan Kőszegi captured and imprisoned Andrew III during his journey to Slavonia for a brief time in August, as the Annales Mellicenses recorded. He entrusted his loyal castle warriors in Moson Castle to guard the prisoner. Andrew was liberated within four months, after his supporters sent their relatives as hostages to Ivan Kőszegi (one of them died in captivity). As a result of their actions, Ivan and Nicholas (who did not support the king's imprisonment) successfully avoided the destruction of their castles, and Ivan even regained Németújvár.
His protege Charles Martel died in August 1295, leaving Ivan without external support. Andrew III married Agnes, the daughter of Duke Albert of Austria in February 1296. Afterwards, with his father-in-law's support, Andrew launched another war against the Kőszegis in August 1296. While the Austrian troops besieged some of Ivan's castles, Archbishop Lodomer excommunicated the brothers. By October, the royal army managed to capture only Kőszeg and two other forts from Ivan Kőszegi. While Ivan Kőszegi remained rebellious for the remaining part of the reign of Andrew, his brother Nicholas pledged allegiance to the monarch after the 1296 rebellion, their political orientations had separated from each other. Around that year the emerging Matthew Csák overshadowed the Kőszegis as the monarch's most dangerous enemies. The river Danube marked the border between the developing domains of the Kőszegi and Csák families. After the close of the 1298 diet, Andrew III entered into a formal alliance with five influential barons – Amadeus Aba, Stephen Ákos, Dominic Rátót, Demetrius Balassa and Paul Szécs – who stated that they were willing to support him against the "rebellious lords", which term definitely primarily covered Matthew Csák and the Kőszegi brothers. Ivan Kőszegi still supported the claim of the House of Anjou. After his election, the pro-Angevin Archbishop Gregory Bicskei absolved Ivan and Henry from the excommunication in March 1299, upon the order of Pope Boniface VIII. Bicskei resided in Transdanubia under the protection of Ivan; he even moved to Szentkereszt Castle beyond the Drava river between Koprivnica and Križevci, owned by Ivan Kőszegi, who remained the only rebellious member of his family by that year (Nicholas died soon and Henry attended the national diet and acted as one of the mediators between Bicskei and his pro-Andrew suffragans). Ivan Kőszegi was among the group of those powerful lords, who urged Charles II of Naples to send his grandson, the 12-year-old Charles Robert, to Hungary in order to become king.
However, by the young pretender's arrival in the summer of 1300, the Kőszegis and Matthew Csák were shortly reconciled with Andrew, preventing Charles' success. Historian Attila Zsoldos argued Andrew III entered into a new feudal contract with the barons in the summer of 1300: Matthew Csák and Ivan Kőszegi (who was the most senior member of the family after Nicholas' death) became "perpetual" Palatines and Andrew accepted their suzerainty over their provinces, while the king's two most powerful partisans, Amadeus Aba and Stephen Ákos were also granted this privilege. In addition to them, two co-palatines of the previous year, Roland Rátót and Apor Péc also received the title as a counterweight, according to Zsoldos' theory.

### During the Interregnum

Andrew III died on 14 January 1301. With his death, the Árpád dynasty became extinct. Ivan Kőszegi was a central figure of the subsequent period of interregnum, which lasted for seven years and various claimants – Charles of Anjou, Wenceslaus of Bohemia, and Otto of Bavaria – fought for the Hungarian throne. Taking advantage of the emerging chaotic situation, Ivan cooperated with his former rival and enemy, Hermann von Landenberg and seized the Pannonhalma Abbey and its surrounding lands. His family unlawfully possessed the abbey until their downfall in 1317. In the following months, Ivan also captured the royal castle of Óvár.
In the early 14th century, Hungary had disintegrated into about a dozen independent provinces, each ruled by a powerful lord, or oligarch. Among them, Matthew Csák dominated the northwestern parts of Hungary (which now form the western territories of present-day Slovakia), Amadeus Aba controlled the northeastern lands, Ivan and Henry Kőszegi ruled Transdanubia and the northern parts of Slavonia, James Borsa dominated Tiszántúl, and Ladislaus Kán governed Transylvania. Ivan Kőszegi was referred to as Palatine since February 1302. In the upcoming years, seven barons held the dignity simultaneously. Majority of the historians, including Gyula Kristó and Jenő Szűcs, considered, these barons, for instance, Matthew Csák, Amadeus Aba, Ivan Kőszegi and Stephen Ákos were arbitrarily styled themselves palatines, usurping the position, which marked its devaluation. However, in accordance with Attila Zsoldos' theory (as presented above), the claimants to the Hungarian throne inherited Andrew's last decision, and they were forced to accept the status quo. As Zsoldos emphasized the oligarchs recognized each other's titles, in addition to the monarchs, cathedral chapters and other institutions. Accordingly, Ivan Kőszegi was considered a "perpetual" Palatine, alongside other powerful lords. He performed his judicial role in his territorial province (Sopron, Vas and Zala counties), in addition to Veszprém County, where acted as a judge in June 1303 in a lawsuit between the chapter of Veszprém and some local nobles over the ownership of Csopak. Beside his dignity of Palatine, Ivan was also styled as ispán of Moson and Sopron counties in 1303.
Immediately after Andrew's death, Charles of Anjou hurried to Esztergom where he was crowned king irregularly. Being Pope Boniface VIII's candidate for the Hungarian throne, Charles had always been unpopular, because the Hungarian lords feared that they would "lose their freedom by accepting a king appointed by the Church", as the Illuminated Chronicle narrates. Despite his nominal pro-Angevin standpoint in the 1290s, Ivan Kőszegi was among those lords, who supported Wenceslaus II of Bohemia. According to the narration of the Steirische Reimchronik, after Wenceslaus II met the Hungarian delegation in Hodonín in the summer of 1301, the Bohemian king sent his envoy to Kőszegi and invited him to a personal meeting. The chronicle says Kőszegi departed Hungary from his castle of Kapuvár to Bohemia. There, instead of himself, Wenceslaus II offered his eleven-year-old namesake son, who was not only Béla IV's great-great-grandson, but also the bride of the late Andrew III's daughter, Elizabeth, for the throne of Hungary. Ivan Kőszegi got a night-time thinking time. Returning to his accommodation, he found 1000 silver coins, many gold and silver treasures and scarlet broadcloth there. On the following day, Kőszegi accepted the king's offer, also referring to the generosity of the late Ottokar II, Wenceslaus' father, who had create him knight of Teutonic Order during his exile decades earlier. However, Kőszegi's main motivation behind his support was to defend his province against the House of Habsburg; Wenceslaus' opponent Charles of Anjou was the nephew of Duke Albert, who intended to enter alliance with his maternal relatives.
Ivan and Henry were among those Hungarian lords, who moved to Brno in order to welcome the young Wenceslaus, who arrived to Hungary with his father's army. While Buda fell into Wenceslaus' arms, the castle of Esztergom was conquered by Ivan Kőszegi, expelling its pro-Angevin residents, including his former ally, Archbishop Gregory Bicskei. Subsequently, he handed the fort over to Bohemian royal mercenaries in return for a significant sum of money. Wenceslaus was crowned king with the Holy Crown by John Hont-Pázmány, Archbishop of Kalocsa on 27 August 1301. Ivan also attended the ceremony. After Wenceslaus's coronation, Charles withdrew to Ugrin Csák's domains in the southern regions of the kingdom. Charles and his general Stephen Csák laid siege to Buda, the capital of Wenceslaus' kingdom, in September 1302, but the arriving Ivan Kőszegi relieved the siege. Despite Pope Boniface declared Charles the lawful king of Hungary on 31 May 1303, Ivan remained a partisan of Wenceslaus. However many lords left the court of the Přemyslid king and pledged loyalty to his rival in the following months, including Stephen Ákos and the Rátóts. Historian Tamás Kádár argues Matthew Csák, who also left Wenceslaus in the same period but did not support Charles either, had tensions with Ivan over the affiliation of Komárom County, inheriting their rivalry from their fathers, and their conflicts of interest caused his departure.
On Kőszegi's advice, as the Steirische Reimchronik emphasizes, Wenceslaus II of Bohemia came to Hungary at the head of a large army in May 1304 to strengthen his son's position. The Bohemians entered the border at Holics (present-day Holíč, Slovakia), Ivan and his "relatives" joined his accompaniment. Marching towards the center of the kingdom, Wenceslaus recaptured Esztergom, looting its treasury, and handed it over to Ivan Kőszegi in June. However, his negotiations in Buda with the local lords convinced him that his son's position in Hungary had dramatically weakened, thus decided to take him back to Bohemia. The young Wenceslaus did not renounce Hungary and made Ivan Kőszegi governor of his realm before leaving for Bohemia in August. The Bohemian king even took the Holy Crown with himself to Prague. The Steirische Reimchronik and a charter of Thomas II, Archbishop of Esztergom suggest that Ivan was the source of ideas for this action too. After the outbreak of scandal, Ivan Kőszegi faced general uproar and anger against his person; the barons blamed him for having lost the crown jewels. In response, Ivan promised through Bishop Benedict Rád to recover the Holy Crown from Bohemia within a year, if they guarantee his safety. Thereafter, according to the Steirische Reimchronik, the "crafty palatine" sent a letter to Duke Otto of Bavaria, Béla IV's grandson, and invited him to the Hungarian throne. Accordingly, Ivan wrote in his letter that Otto can prove his ability by acquiring the crown from the Bohemian court. The Illuminated Chronicle also confirms the Kőszegis initiated the arrival of the Bavarian duke to Hungary. After signing an alliance with his cousin, Charles and Rudolph III of Austria jointly invaded Bohemia in autumn 1304. His army plundered the nearby landholdings in Sopron and Moson counties, owned by Ivan Kőszegi and marched into Moravia. According to the short-spoken Anonymi Leobiensis Chronicon, Charles launched a royal campaign against Ivan Kőszegi in 1305; receiving assistance from Rudolf III, he captured the rebellious lord' three unidentified forts. The Kőszegis looted and plundered the surrounding region with their raids from the occupied fort of Esztergom. Therefore, residing in Székesfehérvár, Archbishop Thomas excommunicated Ivan and Henry for their crimes against the burghers of Esztergom in July 1305. He also placed their provinces under interdict.
After negotiations, Wenceslaus abandoned his claim to the Hungarian throne in favor of Otto and handed the Holy Crown over to him in Brno on 9 October 1305. When Otto arrived to Sopron, he sent his envoys to the local oligarch Ivan Kőszegi, whose first question was whether he brought the crown with him. After a favorable response, Ivan Kőszegi moved to Sopron too and escorted Otto into Buda, who reached the capital around 11 November 1305. Ivan Kőszegi attended his coronation on 6 December in Székesfehérvár. Thereafter Ivan Kőszegi retired from the public affairs and stayed away from further events. Charles seized Esztergom and Visegrád from the Kőszegis in June 1306, and thereafter also captured the many fortresses in the northern parts of Hungary (now in Slovakia), owned by Demetrius Balassa and his family. Around the same time, the Austrian troops also plundered Ivan's estates in Győr and Sopron counties. Ivan did not acknowledge Charles as his king even after Otto's imprisonment and departure from Hungary. He was absent from that assembly in October 1307, where Charles' claim to the throne was confirmed. According to the Steirische Reimchronik, Ivan Kőszegi died on 5 April 1308. His province and wealth were inherited by his grandson Nicholas.