The Princess Bride

In the framing story, a man (Peter Falk) reads a book, The Princess Bride, to his sick grandson (Fred Savage). Scenes of the reading occasionally interrupt the main story; for example, when the boy tells his grandfather to skip the parts that include kissing.
Buttercup (Robin Wright) has grown up on a farm in the Renaissance Era, in the (fictional) country of Florin. She mercilessly orders around the farmhand, Westley (Cary Elwes), but he only replies "As you wish" to her every whim. Buttercup eventually comes to understand that this is his expression of love, which she then comes to return. Westley leaves to seek his fortune so that they might marry, but Buttercup learns that Westley's ship was attacked by the legendary Dread Pirate Roberts, who is infamous for leaving no one alive. Accordingly, Westley is presumed dead.
Five years later, Buttercup reluctantly agrees to marry Humperdinck (Chris Sarandon), the Crown Prince of Florin. Before the wedding, she is kidnapped by a trio of bandits: a Sicilian boss named Vizzini (Wallace Shawn), a giant named Fezzik (AndrÃ© the Giant), and a Spanish master swordsman named Inigo Montoya (Mandy Patinkin), who is seeking revenge against his father's murderer, whom he knows to have six fingers on his right hand. These three are in Humperdinck's employ and have been ordered to kill Buttercup once in Guilder, Florin's enemy, as a pretext to start a war. The four are soon followed by a man dressed in black, and Vizzini orders Inigo and Fezzik to kill him. The man in black bests Inigo in swordplay, knocking him out with the butt of his sword, then chokes Fezzik unconscious in melee combat, and finally tricks Vizzini into drinking lethal poison during a battle of wits, and thereby frees Buttercup.
Buttercup, believing the man in black to be the Dread Pirate Roberts, tries to escape and pushes him down a steep hill, but when he shouts "As you wish" as he falls, she realizes he is her beloved Westley and throws herself down the hill after him. As Westley escorts her back to Florin across a hazardous bog called the Fire Swamp, he explains that though he was captured, the previous Roberts, intrigued by Westley's pleas for mercy and his stories about Buttercup, befriended Westley and trained him in fighting and swordsmanship, and after secretly revealing that he was not the original Roberts (he inherited the title), he eventually retired and bequeathed the title to Westley. Humperdinck, Count Rugen (Christopher Guest) and their men eventually capture Westley and Buttercup and take them back to Florin; Humperdinck later tells Buttercup he has let Westley return to his ship, but in reality Rugen and the Albino (Mel Smith) are torturing Westley in a secret laboratory called the Pit of Despair, using a torture machine to drain the life from him. When Buttercup tells Humperdinck that he is a coward and that she still loves Westley, Humperdinck locks her in a suite, rushes to the Pit and, ignoring Rugen's warning, engages the machine at its highest setting, sending a screaming Westley to his death.
Fezzik, having reunited with a drunk Inigo in a nearby village, has learned that Rugen is the six-fingered man Inigo seeks, but, with the castle secured for Humperdinck's wedding, believes they need the Man in Black's (Westley's) help to invade. Fezzik sobers up Inigo, they stumble upon the Albino, and Fezzik inadvertently kills him when trying to receive information on Westley and Rugen. Westley's dying screams lead them to the Pit, and they recover his body, bringing it to Miracle Max (Billy Crystal), a bitter and destitute apothecary whose confidence had been shattered due to his banishment from the castle by Humperdinck. Max notes that Westley is "only mostly dead", but sustained by true love, and provides a potion (in the form of a chocolate-covered pill) that brings him back to life. Outside the castle gate, Inigo and Fezzik give Westley the pill; he quickly begins to recover, and comes up with a plan to defeat the castle guards and get into the castle itself.
Hearing the commotion outside, Humperdinck panics and orders the priest to declare him and Buttercup married. Having scared the soldiers off, Inigo, Fezzik and Westley make their way into the castle corridors and are intercepted by Rugen and his men; Inigo quickly dispatches the men and introduces himself to Rugen:
"Hello, my name is Inigo Montoya. You killed my father. Prepare to die."
Rugen beats a cowardly retreat with Inigo in pursuit; leaving Westley in the hallway, Fezzik runs to help Inigo, who ultimately confronts Rugen. Rugen injures Inigo multiple times, but strengthened by his determination to exact revenge, Inigo overpowers and kills Rugen. Meanwhile, Westley somehow finds his way into the honeymoon suite and stops Buttercup just as she is about to kill herself; Westley points out to her that because she did not say "I do", the ceremony was not properly completed; therefore, the marriage is not valid. When Humperdinck arrives ready to kill him once and for all, Westley bluffs being at full health and forces Humperdinck to stand down and turn over Buttercup; she ties him to a chair and they all leave him alone with his cowardice.
As Buttercup, Westley, Inigo and Fezzik prepare to leave (on four white horses Fezzik found), Inigo wonders about what he will do with his life now that he has fulfilled his vow; Westley suggests he take up piracy saying "You'd make a wonderful Dread Pirate Roberts."
In the framing story, the grandson allows the grandfather to read on about Westley and Buttercup sharing a passionate kiss. As the grandfather finishes the story and prepares to leave, the boy asks him to read the story again the next day. The grandfather smiles and replies, "As you wish."

Question: Who banished Miracle Max from the castle?
Answer: Humperdinck.