Was the "spirit of Samuel" that the witch of Endor summoned (1st Samuel 28:11-19) from God or from Satan?
Commentators do not all agree on what happened here, but from the context the most plausible is that God overtook the wicked witch with a vision of Samuel to rebuke Saul. The rebuke is even in part for wickedly seeking a medium in the first place.
God on occasion put additional sting and irony into his rebukes by taking a strange person to act as his temporary messenger, which he would usually never do. For example, he rebuked Balaam with a Donkey in Numbers 22:28 and Balaam himself was used to temporarily transmit messages from God to King Balak, though neither were godly men. Balaam thought we was a sort of mediator between gods and Balak was trying to use him to manipulate the god of the Jews, so God made a mockery of them both by using Balaam as his temporary mouthpiece in some ways.
The reason why this seems the most plausible is found within the text itself. Once the witch sees the vision, she is in ‘shocked’ and ‘cried out at the top of her voice’. This shock either meant that she had never before experienced a vision (which God was giving her to her amazement) or she usually had some kind of wicked deceiving vision from devils which was very different from this.
That she is not just ‘faking things’ is proven by the fact that her shock immediately brings her to the realization that the ‘disguised person’ asking her to summon Samuel is Saul! She is afraid because Saul only drove out witches from the land and she knew they deserved to be put to death. (Lev 20:27) It might be asked how did seeing Samuel make her recognize Saul? It seem the vision gave her knowledge of the actors involved and it included recognizing who stood before her in disguise as Samuel had a word of rebuke to Samuel standing there. The vision thus encompasses Saul.
It is therefore implausible to either think the vision came from the Devil as it communicated God’s message, or that it was just a juggling magic act, as the witch herself is inexplicably shocked. It must have been from God through a wicked vessel.
All along I have been assuming it to be a vision and not really Samuel. I do not think Samuel would literally ascend from Sheol, a place beneath the earth where it was thought the dead resided. Rather as parts of visions may be more like parables with certain elements not intended to be literal, this ascending from Sheol would simply indicate in imagery that the witch could understand that Samuel was coming back from the dead, as Saul had asked her to perform as a medium.