It looked as though both sides would be forced to settle for a point, but Roy Hodgson's side struck through Mamadou Sakho in the second minute of stoppage time to rescue a much-needed victory for the Eagles.
Clear chances were few and far between in the opening 45 minutes, though, and Shaqiri was the next to come close shortly after the half-hour mark with a curling effort which went wide of the target.
Palace perhaps should have broken the deadlock five minutes later when the ball rebounded to James McArthur, but the midfielder was denied from point-blank range by Grant as the two sides went into the break still goalless.
Christian Benteke continued his recovery from injury as a half-time sub and almost made a quick impact when his strike hit the side-netting, although just a minute later Stoke were the team celebrating with the opening goal of the contest.
Shaqiri collected the ball on the right flank before weaving his way inside and firing his finish past Wayne Hennessey into the bottom corner to cap off a fine solo effort.
The Potters' lead lasted just three minutes, though, as Loftus-Cheek opened his Palace account in timely fashion to restore parity, smuggling his finish in at the near post after Andros Townsend's deep cross had gone all the way through to him.
Ryan Shawcross could then only divert the ball away from the Palace goal from point-blank range with just three minutes remaining of normal time, and that proved to be a pivotal moment in the game as Palace scored the winner in the 92nd minute.
Another cross from the left went all the way through to the back post and this time Yohan Cabaye was waiting to drill an effort towards goal. The Frenchman saw his strike hit the upright, but the ball bounced kindly for Sakho to apply the finishing touch and send Selhurst Park into raptures.
The result sees Palace close the gap on safety to just three points courtesy of what is now a four-match unbeaten streak at home, whereas Stoke slump to 15th in the table with only three points separating them from the relegation zone.
Crystal Palace (4-4-2): Hennessey; Ward, Tomkins, Sakho, Schlupp; Cabaye, Milivojevic, McArthur (Benteke, 46'), Loftus Cheek; Townsend, Zaha
Stoke City (3-4-3): Grant; Zouma, Wimmer, Shawcross; Pieters, Fletcher, Allen, Diouf (Jese, 74'); Shaqiri, Sobhi (Crouch, 67'); Choupo-Moting body check tags ::