Grezgorz Krychowiak drilled in the winning spot-kick after Granit Xhaka had missed Switzerland’s second penalty to send the Polish fans at the Geoffroy Guichard stadium into raptures.
The Poles will meet Croatia or Portugal, who play later on Saturday, for a berth in the semis.
Jakub Blaszczykowski had given Poland a 39th-minute lead before Shaqiri levelled with a spectacular bicycle kick in the 82nd to send the contest into a dramatic climax.
“We were prepared for this kind of battle,” Poland coach Adam Nawalka said. “The Swiss are a world class side and it was no surprise that they came storming back in the second half.
“But the important thing is that my team showed potential after conceding the equaliser. We are mentally prepared for the quarter-final match in Marseille on Thursday.”
Man of the match Shaqiri, who was superb in the second half and extra time, said the goal meant little after a painful loss.
“It’s a great disappointment, we could have achieved something very big,” the 24-year old forward told a news conference.
“It was a beautiful goal and I am always proud to score for my country, but we are out.”
Poland dominated the first half and should have gone ahead inside the first minute when Arkadiusz Milik sent his shot over a gaping goal following a calamitous defensive mix-up.
With striker Robert Lewandowski subdued, the Poles created had to rely on chances created by livewire left winger Kamil Grosicki and the impressive Blaszczykowski on the other flank.
Switzerland captain Stephan Lichsteiner could not keep up with Grosicki, who fired over the bar from 18 metres after a clever run through the middle.
Blaszczykowski broke the deadlock with a composed finish from 10 metres after a darting run by Grosicki and a dummy from Milik gave the winger time and space to pick his spot.
With Shaqiri and striker Haris Seferovic stifled by Poland’s rock-solid defence, the Swiss created little in the opening period despite roaring “Go Suisse” chants by their supporters.
They came out with renewed purpose in the second half and Shaqiri finally showed a glimpse of his talent with a dazzling solo run and a stinging shot which Lukasz Fabianski parried.
Blaszczykowski had Yann Sommer at full stretch as the pace increased with Switzerland throwing men forward.
Shaqiri produced a moment of magic with one of the best goals of the tournament in the 82nd minute, twisting his body in the air to unleash a fierce shot which gave Fabianski no chance as it went in off the post.
Galvanised by the goal, Switzerland took the upper hand and dominated extra time, forcing several desperate clearances by a defence which had conceded in only one other match in 2016.
Substitute Eren Derdiyok missed a sitter for the Swiss when Fabianski kept out his close-range header and they paid the price as a rattled Poland held on to force the shootout.