Andrew was the second of three surviving sons of King Charles I of Hungary and his third wife, Elizabeth of Poland. He was betrothed in 1334 to his cousin Joanna, granddaughter and heiress apparent of King Robert of Naples; Andrew's father was a fraternal nephew of King Robert, making Andrew and Joanna both members of the Capetian House of Anjou. Robert's claim to the throne was rather tenuous and did not follow primogeniture. Andrew's grandfather, Charles Martel of Anjou, had died young; therefore, the throne should have passed to Andrew's father. However, due to fears of impending invasion from Sicily, it was felt that a seven-year-old heir was too risky and would not be able to hold off invasions. The throne was offered to the next son of Charles II of Naples, Louis, but he refused on religious grounds, and it thus passed to Robert. To recompensate Andrew's father, Charles II decided to assign him the claim to Hungary. When King Robert died in 1343, in his last will and testament, he formally bequeathed his kingdom to his granddaughter Joanna, making no mention of Andrew and thus denying him the right to reign along with Joanna.
With the approval of Pope Clement VI, Joanna was crowned sole monarch of Naples in August 1344. Fearing for his life, Andrew wrote to his mother Elizabeth that he would soon flee the kingdom. She intervened, and made a state visit, before she returned to Hungary allegedly bribing Pope Clement to reverse himself and permit the coronation of Andrew. She also gave a ring to Andrew, which was supposed to protect him from death by blade or poison, and returned with a false sense of security to Hungary. When Joanna fell ill in the summer of 1344, Andrew caused great controversy when he released the Pipini brothers. They had been locked up by Robert the Wise after having been convicted for murder, rape, pillage, treason and several other offences. Their possessions had been given to other nobles, who now became increasingly hostile to Andrew.
Murder and aftermath
Hearing of the Pope's reversal, a group of noble conspirators determined to forestall Andrew's coronation. During a hunting trip at Aversa, Andrew left his room in the middle of the night and was set upon by the conspirators. A treacherous servant barred the door behind him, and, as Joanna cowered in their bed, a terrible struggle ensued, Andrew defending himself furiously and shrieking for aid. He was finally overpowered, strangled with a cord, and flung from a window. Isolde, Andrew's Hungarian nurse took the Prince's corpse to the church of the monks, and remained with it until next morning mourning it. When the Hungarian knights arrived she told them everything in their mother tongue so no one else would learn about the truth, and soon they left Naples reporting everything to the Hungarian King. The deed would taint the rest of Joanna's reign, although she was twice acquitted of any charge in the trials that followed. Andrew's elder brother Louis I of Hungary several times invaded the Kingdom of Naples and drove out Joanna, only to meet with reverses. Ultimately, 37 years later, their kinsman Charles III of Naples conquered Naples with Hungarian aid and put Joanna to death. She had been married three times more since Andrew. Andrew and Joanna had one posthumous son, Charles Martel who died young in Hungary.