Magic Resistance. Beferius has advantage on saving throws against spells and other magical effects.
Magic Weapons. Beferius's weapon attacks are magical.
Innate Spellcasting. Beferius's spellcasting ability is Charisma (spell save DC 21). Beferius can innately cast the following spells, requiring no material components:
At will: detect magic, fireball
3/day each: counterspell, dominate monster, teleportation, dispel magic
1/day each: dominate monster, feeblemind, planeshift, *Summons
*roll a d20. Summons a creature of a CR equal to that number of a chosen creature type
Legendary Resistance (3/Day). If Beferius fails a saving throw, he can choose to succeed instead.
Teleportation. Beferius magically teleports, along with any equipment he is wearing or carrying up to 120 feet to an unoccupied space he can see.
Multiattack. Beferius makes four attacks: one with its bite, one with the Spine of the First, and one with its tail.
Bite. Melee Weapon Attack: +16 to hit, reach 5 ft., one target. Hit: 22 (4d6 + 8) piercing damage. The target must succeed on a DC 21 Constitution saving throw or become poisoned. While poisoned in this way, the target can't regain hit points, and it takes 21 (6d6) poison damage at the start of each of its turns. The poisoned target can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success.
Spine of the First. Melee Weapon Attack: +16 to hit, reach 15 ft., one target. Hit: 15 (2d6 + 8) bludgeoning damage plus 21 (6d6) fire damage.
Tail. Melee Weapon Attack: +16 to hit, reach 10 ft., one target. Hit: 24 (3d10 + 8) bludgeoning damage.
Beferius can take 3 legendary actions, choosing from the options below. Only one legendary action option can be used at a time and only at the end of another creature's turn. Beferius regains spent legendary actions at the start of his turn.
Attack. Beferius makes a melee attack with the Spine of the First.
Summons (Costs 3 Actions). Beferius casts summons but it can only be cast once per day as a legendary action.
Teleport. Beferius uses his Teleport action.