The legendary king VikramÄditya (Vikrama) promises a vamachari (a tantric sorcerer) that he will capture a vetala (or Baital), a celestial spirit Pishacha, celestial spirit analogous to a vampire in Western literature who hangs from a tree and inhabits and animates dead bodies.
King Vikrama faces many difficulties in bringing the vetala to the tantric. Each time Vikram tries to capture the vetala, it tells a story that ends with a riddle. If Vikrama cannot answer the question correctly, the vampire consents to remain in captivity. If the king knows the answer but still keeps quiet, then his head shall burst into thousand pieces. And if King Vikrama answers the question correctly, the vampire would escape and return to his tree. He knows the answer to every question; therefore the cycle of catching and releasing the vampire continues twenty-four times.
On the twenty-fifth attempt, the Vetala tells the story of a father and a son in the aftermath of a devastating war. They find the queen and the princess alive in the chaos, and decide to take them home. In due time, the son marries the queen and the father marries the princess. Eventually, the son and the queen have a son, and the father and the princess have a daughter. The vetala asks what the relation between the two newborn children is. The question stumps Vikrama. Satisfied, the vetala allows himself to be taken to the tantric.
On their way to the tantric, Vetala tells his story. His parents did not have a son and a tantric blessed them with twin sons on a condition that both be educated under him. Vetala was taught everything in the world but often ill treated. Whereas his brother was taught just what was needed but always well treated. Vetala came to know that the tantric planned to give his brother back to his parents and Vetala instead would be sacrificed as he was an 'all- knowing kumara' and by sacrificing him the tantric could be immortal and rule the world using his tantric powers. Vetal also reveals that now the tantric's plan is to sacrifice Vikram, beheading him as he bowed in front of the goddess. Then tantric could then gain control over the vetala and sacrifice his soul, thus achieving his evil ambition. The vetala suggests that the king asks the tantric how to perform his obeisance, then take advantage of that moment to behead the sorcerer himself. VikramÄditya does exactly as told by vetala and he is blessed by Lord Indra and Devi Kali. The vetala offers the king a boon, whereupon Vikram requests that the tantric's heart and mind be cleaned of all sins and his life be restored as a good living being and that the vetala would come to the king's aid when needed.

Question: Why did the Tannic want to behead Virkama?
Answer: To gain control of the Vetala
Alternative answer: gain control