After his predecessor Wamba had taken the monastic habit while on the verge of death, he was forced to retire from the kingship, even though he recovered, and enter a monastery. He appointed Erwig his successor and the latter was anointed in Toledo on 31 October 680. Later, 9th-century legends attributed to Erwig the poisoning of the king, who was made a penitent by his supporters while Erwig's supporters raised him to the throne. The bishops of the Twelfth Council of Toledo, which Erwig opened on 9 January 681, confirmed that the documents of abdication and confirmation of Erwig from Wamba were authentic and contained his own signature. Nonetheless, some historians have seen in the rapidity of Erwig's unction after the king had received the penitential sacrament evidence for a pre-planned palace coup.
Erwig began his reign in a climate of uneasiness concerning the way in which he reached the throne. Probably feeling insecure himself, the nobles and bishops took advantage. Erwig restored to favour those who had been out of it in the time of Wamba. After the Twelfth Council, the Thirteenth (683) and Fourteenth (684) followed in quick succession. The councils confirmed Erwig's legitimacy for a second time and wrote many laws to protect the life and rule of the king and his family, including that of his queen, Liuvigoto.
After falling seriously ill, Erwig proclaimed his son-in-law Ergica, the husband of his daughter Cixilo, as his heir on 14 November 687 and retired to a monastery as a penitent the next day, after giving leave to his court to return to Toledo with Egica for the anointing and crowning.