Recently divorced Meg Altman and her 11-year-old daughter Sarah have just purchased a four-story brownstone on the Upper West Side of New York City. The house's previous owner, a reclusive millionaire, installed an isolated room used to protect the house's occupants from intruders. The "panic room" is protected by concrete and steel on all sides, a thick steel door, and an extensive security system with multiple surveillance cameras, a public announcement system, and a separate phone line. On the night the two move into the home, it is broken into by Junior (Leto), the previous owner's grandson; Burnham (Whitaker), an employee of the residence's security company; and Raoul (Yoakam), a ski mask-wearing gunman recruited by Junior. The three are after $3 million in bearer bonds, which are locked inside a floor safe in the panic room.
After discovering that the Altmans have moved in earlier than expected, Junior convinces a reluctant Burnham, who assumed the house was unoccupied, to continue with their heist. As they begin the robbery, Meg wakes up and happens to see the intruders on the video monitors in the panic room. Before the three can reach them, Meg and Sarah run into the panic room and close the door behind them. They are unable to use the phone in the room which has a separate phone line that was never hooked up by Meg. Intending to force the two out of the room, Burnham introduces propane gas into the room's air vents. Raoul, in conflict with Burnham and Junior, dangerously increases the amount of gas. Unable to seal the vents, Meg ignites the gas while she and Sarah cover themselves with fireproof blankets, causing an explosion which vents into the room outside and causes a fire, injuring Junior.
The Altmans make several attempts to call for help, including signaling a neighbor with a flashlight through the opening of a ventilation pipe, but the neighbor ignores it. Meg then taps into the main telephone line and gets through to her ex-husband Stephen (Bauchau), before the burglars cut them off.
When all attempts to get into the room fail, Junior lets slip that there is much more money in the safe than he let on, and gives up on the robbery. About to leave the house, he is shot by Raoul, who forces Burnham, at gunpoint, to finish the robbery. Stephen arrives at the home and is taken hostage by Burnham and Raoulâwho severely beats him. To make matters worse, Sarah, who has diabetes, suffers a seizure. Her emergency glucagon syringe is in a refrigerator outside the panic room. After using an unconscious Stephen to trick Meg into momentarily leaving the panic room, Burnham enters it, finding Sarah motionless on the floor. After retrieving the syringe for Sarah, Meg struggles briefly with Raoul, who is thrown into the panic room, his gun knocked out of his hand. As Meg throws the syringe into the panic room, Burnham frantically locks himself, Raoul, and Sarah inside, crushing Raoul's hand in the sliding steel door. Meg, who now has the gun, begs the two intruders over the PA system to give Sarah the injection. After some time Burnham, who has shown no interest in hurting either Meg or Sarah throughout the film, gives Sarah the injection. While doing so, he tells Sarah he did not want this, and the only reason he agreed to participate was to give his own child a better life. After Burnham gives Sarah the injection, Sarah thanks him and he tells Meg that Sarah is now alright.
Having earlier received a call from Stephen, two policemen arrive, which prompts Raoul to threaten Sarah's life. Sensing the potential danger to her daughter, Meg lies to the officers and they leave. Meanwhile, Burnham opens the safe and removes the $22 million in bearer bonds inside. As the robbers attempt to leave, using Sarah as a hostage, Meg hits Raoul with a sledgehammer and Burnham flees. After a badly injured Stephen shoots at Raoul and misses, Raoul disables him and prepares to kill Meg with the sledgehammer, but Burnham, upon hearing Sarah's screams of pain, returns to the house and shoots Raoul dead, stating, "You'll be okay now", to Meg and her daughter before leaving. The police, alerted by Meg's suspicious behavior earlier, arrive in force and capture Burnham, who lets the bearer bonds go; they fly away with the wind.
Later, Meg and Sarah, having recovered from their harrowing experience, begin searching the newspaper for a new home.

Question: Where did Meg get a gun?
Answer: It was knocked out of Raoul's hand during their struggle
Alternative answer: She knocks it out of Raoul's hand