When the King of the land asked for a wizard to teach him magic, no real witches or wizards came, because the King had issued a decree on witch hunting, but the Charlatan came and pretended to be a wizard when he was just a Muggle.
He pretended to teach the King magic, which of course didn't work, but then he and the King heard laughter coming from Babbity's cottage (Babbity was a real witch). Hearing the laughter, the King was angered, and then he had Babbity bought before him, but the Charlatan asked her to help him, in private, and she berated him but said she would.
So she did all the spells for him - except the one where the King asked her to resurrect his dog; she did nothing, the Charlatan said it was not working. This is because real magic cannot raise the dead. But the Charlatan ordered Babbity arrested, and then Babbity ran from the witch hunter Muggles, and then she turned into a tree, then the Charlatan ordered it cut down because "that's what you do with real evil witches" and then Babbity laughed when the tree was cut, saying that real witches survive to cut, and said that the Muggles ought to try it on the Charlatan.
The foolish man confessed his evil and was then imprisoned in a dark dungeon. It's likely that he was either forced to remain there for the rest of his miserable life, executed some time afterwards or eventually released in disgrace and humiliation.