The defeats, including one in a previously safe seat, could renew speculation about Johnson's future after he earlier this month survived a move by his own party against him.
Johnson has come under intense pressure to resign after he was fined for breaking COVID-19 lockdown rules following a police investigation into gatherings at his Downing Street offices.
The centrist Liberal Democrat party won the seat of Tiverton and Honiton, in a deeply Conservative part of southwest England, by more than 6000 votes, overturning a majority of more than 24,000 when the Conservatives won the seat in 2019.
The Liberal Democrats said it was the biggest ever majority to be overturned at a British parliamentary by-election, suggesting other Conservative politicians may be at risk of losing their seats in the party's southern heartlands.
"Tonight, the people of Tiverton and Honiton have spoken for Britain. They've sent a loud and clear message: It's time for Boris Johnson to go, and go now," the winning Lib Dem candidate Richard Foord said in his victory speech.
"With every day Boris Johnson clings to office, he brings further shame, chaos and neglect."
In the separate parliamentary seat of Wakefield in northern England, the opposition Labour party also defeated the Conservatives.
Johnson led the Conservatives to their biggest majority in three decades at the 2019 national election, earning praise from his party for his ability to win in traditionally Labour-voting areas in north and central England.
However, the loss of Wakefield could indicate his ability to win again in these areas at the next national election, expected in 2024, has been compromised too.
Johnson on Thursday rejected suggestions he could resign if the Conservatives lost both seats, saying it was common for governing parties to lose mid-term by-elections.
The by-elections were triggered by high-profile resignations of Conservative politicians - one who admitted watching pornography in parliament, and another found guilty of sexually assaulting a teenage boy.Â