Winner Helen Morgan overturned a Tory majority of almost 23,000, declaring that the “party is over” for the PM.
The result follows a torrid week for Mr Johnson, who has faced criticism over Downing Street parties and a rebellion by his own MPs over Covid measures.
Tory MP Sir Roger Gale said the prime minister was on “last orders”.
Conservative Party chairman Oliver Dowden said: “I know that the voters of North Shropshire are fed up and they wanted to give us a kicking… We’ve heard that message loud and clear.”
But he added: “I don’t think this amounts to a sea-change.”
The by-election followed the resignation of Owen Paterson, the MP for North Shropshire since 1997, who was found to have breached parliamentary rules on lobbying.