Being the last male member of the House of Árpád, Andrew was elected king after the death of King Ladislaus IV in 1290. He was the first Hungarian monarch to issue a coronation diploma confirming the privileges of the noblemen and the clergy. At least three pretenders—Albert of Austria, Mary of Hungary, and an adventurer—challenged his claim to the throne. Andrew expelled the adventurer from Hungary and forced Albert of Austria to conclude a peace within a year, but Mary of Hungary and her descendants did not renounce their claim. The Hungarian bishops and Andrew's maternal family from Venice were his principal supporters, but the leading Croatian and Slavonian lords were opposed to his rule.
Hungary was in a state of constant anarchy during Andrew's reign. The Kőszegis, the Csáks, and other powerful families autonomously governed their domains, rising up nearly every year in open rebellion against Andrew. With Andrew's death, the House of Árpád became extinct. A civil war ensued which lasted for more than two decades and ended with the victory of Mary of Hungary's grandson, Charles Robert.
Andrew was the son of Stephen the Posthumous, the self-styled Duke of Slavonia, and his second wife, Tomasina Morosini. Andrew's father was born to Beatrice D'Este, the third wife of Andrew II of Hungary, after the king's death. However, Andrew II's two elder sons, Béla IV of Hungary and Coloman of Halych, accused Beatrice D'Este of adultery and refused to acknowledge Stephen the Posthumous as their legitimate brother. Andrew's mother, Tomasina Morosini, was the daughter of wealthy Venetian patrician Michele Morosini.
The exact date of Andrew's birth is unknown. According to historians Tibor Almási, Gyula Kristó, and Attila Zsoldos, he was born in about 1265. Stephen the Posthumous nominated his wife's two kinsmen, including her brother Alberto Morosini, as Andrew's guardians before his death in 1272.
Andrew came to Hungary for the first time in 1278 at the invitation of a powerful lord, Ivan Kőszegi. Kőszegi wanted to play Andrew off against Ladislaus IV of Hungary. Andrew, who was the only male member of the royal family besides the king, adopted the title of "Duke of Slavonia, Dalmatia and Croatia" and marched as far as Lake Balaton. Andrew achieved nothing, however, and went back to Venice in autumn.
Andrew returned to Hungary at the beginning of 1290. On this occasion, Lodomer, Archbishop of Esztergom, also urged him to come, since the archbishop wanted to dethrone the excommunicated Ladislaus IV with the assistance of Ivan Kőszegi. Before Andrew was successful, Arnold Hahót, an enemy of the Kőszegis, invited him to the fort of Štrigova and captured him. Hahót sent Andrew to Vienna, where Albert I, Duke of Austria, held him in captivity.
Three Cuman assassins murdered Ladislaus IV on 10 July 1290, and Archbishop Lodomer subsequently dispatched two monks to Vienna to inform Andrew of the king's death. With the monks' assistance, Andrew left his prison in disguise and hastened to Hungary.
Upon Andrew's arrival, his opponents tried to bribe Theodor, Prior of the Székesfehérvár Chapter, not to hand over the Holy Crown of Hungary to the soon-to-be-king, but the prior refused them. Archbishop Lodomer crowned Andrew king in Székesfehérvár on 23 July. The lords and prelates swore loyalty to Andrew only after he issued a charter promising the restoration of internal peace and respect for the privileges of the nobility and the clergymen. He then appointed the most powerful noblemen, who had for years administered their domains independently of the monarch, to the highest offices. Amadeus Aba, who dominated the northeastern parts of the kingdom, was made palatine, Ivan Kőszegi, the lord of the western parts of Transdanubia, became master of the treasury, and Roland Borsa remained the voivode of Transylvania. Andrew held a diet before 1 September. To put an end to anarchy, the "prelates, barons and noblemen" ordered the destruction of castles which had been erected without royal permission and the restoration of estates that had been unlawfully seized to their rightful owners. Andrew promised that he would hold a diet each year during his reign.
There were several other challengers to Andrew's claim to the throne. Rudolf I of Germany claimed that Hungary escheated to him after Ladislaus IV's childless death, because Ladislaus IV's grandfather, Béla IV of Hungary, had sworn fidelity to Frederick II, Holy Roman Emperor during the Mongol invasion of Hungary. Although Pope Innocent IV had years before freed Béla IV of his oath, Rudolf I of Germany attempted to bestow Hungary on his own son, Albert of Austria, on 31 August. The self-declared "Andrew, Duke of Slavonia"—an adventurer who claimed to be identical to Ladislaus IV's dead younger brother—also challenged King Andrew's right to the crown and stormed into Hungary from Poland. He was shortly thereafter forced to return to Poland, where he was murdered.
Andrew married Fenenna, the daughter of Ziemomysł of Kuyavia, before the end of 1290. Andrew then held a general assembly for the barons and the noblemen of five counties to the east of the river Tisza—Bihar, Kraszna, Szabolcs, Szatmár, and Szolnok—at Nagyvárad (now Oradea in Romania) in early 1291. The assembly outlawed Stephen Balogsemjén, a staunch supporter of the late Ladislaus IV, for major trespass. From the assembly, Andrew went to Gyulafehérvár (now Alba Iulia in Romania). Here he issued the decrees of his 1290 diet at the assembly of the local noblemen, Saxons, Székelys and Romanians, in February or March. Around the same time, Andrew dismissed Amadeus Aba and made Ivan Kőszegi palatine.
Ladislaus IV's sister Mary, wife of Charles II of Naples, announced her claim to the throne in April 1291. The Babonići, Frankopans, Šubići, and other leading Croatian and Slavonian noble families accepted her as the lawful monarch. Andrew's main concern, however, was Albert of Austria's claim. He invaded Austria, forcing Albert to withdraw his garrisons from the towns and fortresses—including Pressburg (now Bratislava in Slovakia) and Sopron—that he had captured 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, and three days later Andrew and Albert of Austria confirmed it at their meeting in Köpcsény (now Kopčany in Slovakia). The peace treaty prescribed the destruction of the fortresses that Albert of Austria had seized from the Kőszegis. The Kőszegis rose up in open rebellion against Andrew in spring 1292, acknowledging Mary's son, Charles Martel, as King of Hungary. The royal troops subdued the rebellion by July, but the Kőszegis captured and imprisoned Andrew during his journey to Slavonia in August. Andrew was liberated within four months, after his supporters sent their relatives as hostages to the Kőszegis.
Upon Andrew's request, his mother, Tomasina, moved to Hungary in 1293. Andrew appointed her to administer Croatia, Dalmatia, and Slavonia. Due to her activities, the Babonići, Šubići, and the Dalmatian towns, acknowledged Andrew's rule. Andrew visited the northern parts of Hungary and ordered the revision of former land grants in February. After his return to Buda, he again made Amadeus Aba palatine. In August, Andrew arranged a marriage between his niece, Constance Morosini, and Vladislav, son of Stefan Dragutin of Serbia, who had earlier acknowledged Charles Martel's claim to Hungary.
Roland Borsa besieged and captured Benedict, Bishop of Várad's fortress at Fenes (now Finiș in Romania) on 23 May 1294. Andrew held a general assembly and outlawed Borsa. According to historian Attila Zsoldos, he made Nicholas Kőszegi palatine on this occasion. Andrew laid siege to Borsa's fort at Adorján (now Adrian in Romania). The siege lasted three months before the fort fell to Andrew in October. Andrew replaced Roland Borsa with Ladislaus III Kán as voivode of Transylvania, but the former preserved all his domains in the lands east of the Tisza.
The Croatian lord Paul Šubić again turned against Andrew and joined the camp of Charles Martel in early 1295, but Charles died in August. Within two months, the Babonići also rebelled against Andrew. Early the next year, the recently widowed King Andrew visited Vienna and arranged a marriage with Duke Albert's daughter Agnes. The Kőszegis soon rose up in open rebellion. Andrew declared war on the rebels, and Archbishop Lodomer excommunicated them. Andrew and Albert jointly seized the Kőszegis' main fort at Kőszeg in October, but could not subdue them. Andrew's mother seems to have died at the end of the year because references to her activities disappear from the contemporaneous documents.
Matthew III Csák, whom Andrew had made palatine in 1296, turned against Andrew at the end of 1297. Andrew's staunch supporter, Archbishop Lodomer, died around the same time. In early February 1298, Andrew visited Albert of Austria in Vienna and promised to support him against Adolf of Nassau, King of Germany. Andrew sent an auxiliary troop, and Albert of Austria routed King Adolf in the Battle of Göllheim on 2 July.
Andrew held an assembly of the prelates, noblemen, Saxons, Székelys, and Cumans in Pest in the summer of 1298. The preamble to the decrees that were passed at the diet mentioned "the laxity of the lord king". The decrees authorized Andrew to destroy forts built without permission and ordered the punishment of those who had seized landed property with force, but also threatened Andrew with excommunication if he did not apply the decrees. At the gathering, he appointed his uncle, Albertino Morosini, Duke of Slavonia. After the close of the diet, Andrew entered into a formal alliance with five influential noblemen – 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 Pope and the bishops. Gregory Bicskei, the Archbishop-elect and Apostolic Administrator of Esztergom, forbade the prelates to participate at a new diet which was held in 1299. The prelates ignored the archbishop's order and Andrew deprived him of Esztergom County.
A group of powerful lords—including the Šubići, Kőszegis and Csáks—urged Charles II of Naples to send his grandson, the 12-year-old Charles Robert, to Hungary in order to become king. The young Charles Robert disembarked in Split in August 1300. Most Croatian and Slavonian lords and all Dalmatian towns but Trogir recognized him as king before he marched to Zagreb. The Kőszegis and Matthew Csák, however, were shortly reconciled with Andrew, preventing Charles' success. Andrew's envoy to the Holy See noted that Pope Boniface VIII did not support Charles Robert's adventure, either. Andrew, who had been in poor health for a while, was planning to capture his opponent, but he died in Buda Castle on 14 January 1301. According to historians Attila Zsoldos and Gyula Kristó, the contemporaneous gossip suggesting that Andrew was poisoned cannot be proved.
Andrew was buried in the Franciscan church in Buda. Years later, Palatine Stephen Ákos referred to Andrew as the "last golden branch" of the tree of King Saint Stephen's family, because with Andrew's death the House of Árpád, the first royal dynasty of Hungary, ended. A civil war between various claimants to the throne—Charles Robert, Wenceslaus of Bohemia, and Otto of Bavaria—followed Andrew's death and lasted for seven years. The civil war ended with Charles Robert's victory, but he was forced to continue fighting against the Kőszegis, the Abas, Matthew Csák, and other powerful lords up to the early 1320s.
Andrew's first wife, Fenenna of Kuyavia, gave birth to a daughter, Elizabeth, in 1291 or 1292, but died in 1295. Elizabeth became engaged to Wenceslaus, the heir to Wenceslaus II of Bohemia, in 1298, but the betrothal was broken in 1305. She joined the Dominican convent at Töss where she died a nun on 5 May 1338. She is now venerated as Blessed Elizabeth of Töss. Andrew's second wife, Agnes of Austria, was born in 1280. She survived her husband, but did not marry again; she died in the Königsfelden Monastery of the Poor Clares in 1364.