The temple of Phimeanakas is situated near the center of the area enclosed by the walls of the Royal Palace. It is believed that here a serpent-spirit with nine heads lived. The spirit appeared to the Khmer king disguised as a woman and the king had to sleep with her every night in the tower before he joined his wives and concubines in another part of the palace. If the king missed even one night it was believed he would die. In this way the royal lineage of the Khmer was perpetuated.