The defeat was described as "a kicking" for the Conservatives, substantiating fears expressed publicly and privately that the party's reputation and electoral prospects are now suffering under Johnson's leadership.
The centrist Liberal Democrats party candidate, Helen Morgan, won the North Shropshire seat by nearly 6,000 votes, overturning a 23,000-vote Conservative majority from 2019.
"Our country is crying out for leadership. Mr Johnson, you're no leader," Morgan said in her victory speech.
The Conservatives had won every previous election for the mostly rural area of central England since the constituency was created in its current form in 1983. Conservative lawmakers have been dominant in the region for nearly 200 years.
The huge swing comes as British Prime Minister Johnson faces criticism on several fronts, including over reports his staff held parties last Christmas when the country was in lockdown.
"Voters in North Shropshire were fed up and they gave us a kicking and I think they wanted to send us a message," Conservative chairman and lawmaker Oliver Dowden told Sky News. "I want to say as chairman of the Conservative Party, we've heard that loud and clear."
Nationwide opinion polls show Conservatives falling behind their main rivals, the Labour Party, following an outcry over lawmakers' second jobs, criticism of the way Johnson funded the lavish refurbishment of his apartment and a surge in Covid-19 cases.
"This has to be seen as a referendum on the prime minister's performance," Conservative lawmaker Roger Gale, a long-standing critic of Johnson, told the BBC.
"The Conservative Party has a reputation for not taking prisoners. If the prime minister fails, the prime minister goes."
The vote for the North Shropshire seat, one of 650 in Britain's parliament, was called outside of the regular election cycle because the incumbent Conservative resigned after he was found to have broken rules on paid lobbying.
The government attempted to prevent that resignation by changing rules designed to stop corruption in parliament, but was forced to backtrack after the move provoked a backlash over integrity and trust under Johnson's leadership.
British voters often use such by-elections to punish the ruling party, but the scale of the Liberal Democrat victory suggests deep public dissatisfaction with Johnson's government.
It still holds a large majority of the seats in parliament after a comprehensive election win in 2019 built on a promise to 'Get Brexit Done' that united traditional right-leaning Conservative voters with a swathes of new supporters.
North Shropshire was a pro-Brexit, staunchly Conservative area. Analysts say Friday's heavy defeat may further undermine Johnson's authority over lawmakers, some of whom are already in open revolt over plans to introduce Covid-19 passports.
"He needs to change now. He needs to listen to the views of his party," said a senior Conservative lawmaker, who spoke on condition of anonymity. He described Johnson as a talented communicator in need of a better team of advisers.
Any leadership challenge would require 54 of the party's elected lawmakers to formally register their lack of confidence.
For now, that does not seem an imminent threat, with most of Johnson's toughest critics stressing the need for him to improve rather than calling outright for him to go
Britain's next national election is due in 2024.