I Samuel - Chapter 28
King Saul and the Deathly Hallows
King Achish prepared for war against Israel and he appointed David to his personal retinue, thinking he was loyal to the Philistine cause. David answered with an ambiguous, "Just wait until you see what I do!"(At this point, he wasn't 100% sure how he was going to get out of it.)
Meanwhile, Shaul was looking for a sorcerer. Shmuel (Samuel) had died and G-d wasn't sending Shaul any direction through prophets or the Urim and Tumim. Unfortunately for Shaul, he had previously rid the land of sorcerers. (Don't think he spent his whole reign just chasing David; he DID run the country!) He sent his men to find a sorcerer and they located a woman in Endor. (The character "Endora" on the old TV show "Bewitched" gets her name from the famous "witch of Endor.")
Shaul traveled to Endor in disguise, but the witch was hesitant to help; she was afraid this was a case of entrapment. Shaul assured her that no harm would come to her if she helped him. She raised up the ghost of Shmuel for Shaul, which made her realize that her client was the king in disguise. Shaul reassured her that she would not be harmed and asked her to describe the spirit. (The witch could see Shmuel, but not hear him; Shaul could hear him, but not see him.)
Shmuel asked Shaul, "Why have you disturbed my rest?" Shaul explained how G-d wasn't sending him any messages and he needed direction. Shmuel replied that G-d has given the kingdom to David, G-d was going to permit the Philistines to win the upcoming battle, and that Shaul and his sons would be killed. (They would, however, merit their place in the Next World.)
Shaul was so overcome by Shmuel's words that he fell to the ground and refused all food. The witch and his men impressed upon him to eat, which he ultimately did. Shaul and his men departed to meet their fate.
There is a difference of opinion as to whether or not ancient sorcerers actually had any magical abilities. The Radak and others say they did. The Rambam says they didn't and that their deeds were tricks. (Even today there's no shortage of people doing such things.) A third opinion is offered by Rav Saadia Gaon: for the most part these people are frauds, but in this case, G-d permitted Shmuel to be raised in order to give Shaul the prophecy. (We'll see a similar question by a seemingly false prophet who receives a real prophecy in the Book of Kings.)