Andrew was the son of Stephen the Posthumous and Tomasina Morosini, and he was born on 2 January 1265. His father was the posthumous son of Andrew II of Hungary and a member of the House of Arpad; his mother was a Venetian noblewoman. In 1278, the powerful lord Ivan Koszegi invited Andrew to Hungary with the goal of having Andrew overthrow King Ladislaus IV of Hungary and seize power for himself. Andrew styled himself as Duke of Slavonia, Dalmatia, and Croatia, but he achieved nothing in his first invasion, returning to Venice. In 1290, he returned to Hungary, but he was captured by Arnold III Hahot and sent to prison in Vienna, Duchy of Austria under the watch of Albert of Austria. After three Cumans assassinated Ladislaus in 1290, three monks sent by Archbishop Lodomer of Esztergom disguised Andrew and helped him escape from prison, and he became the new King of Hungary.
King of Hungary
On 23 July 1290, Andrew was crowned king in Szekesfehervar, and he swore to protect the privileges of the nobility and the clergy. He also promised to convene the Diet of Hungary each year to help solve the anarchy in the country. However, Rudolf I of Germany claimed the throne on the grounds that King Bela IV of Hungary had sworn allegiance to Frederick II of Germany in exchange for assistance against the Mongol Empire in 1241. An impostor of Andrew, Duke of Slavonia, the late son of the former king Stephen V of Hungary, also claimed the throne, only to be murdered in Poland. Andrew made Ivan Koszegi the new Palatine of Hungary, and they fought against Albert of Austria's claim to the throne. In 1292, the Koszegis betrayed Andrew in favor of naming Charles Martel of the House of Anjou as the new King of Hungary, as he was the maternal grandson of Stephen V. Hungary devolved into anarchy as the nobles and lords changed sides between the Angevins and the loyalists of the House of Arpad, and Charles Martel died in August 1295. Archbishop Lodomer, Andrew's staunch supporter, excommunicated the Koszegis for rebelling, and Andrew's own palatine, Matthew III Csak, turned against him in 1297. In 1298, Andrew allied with Albert of Austria after assisting Albert in slaying Adolf of Germany at Goellheim on 2 July, and he later faced a new threat from Charles Robert of Anjou. He died in Buda in 1301 before he could fight against Charles, and he was the last ruler from the House of Arpad. After his death, his son-in-law Wenceslaus III of Bohemia succeeded him as king, and it would take twenty years for Charles Robert to emerge victorious and bring the House of Anjou to power in Hungary.