Burnham, the Greater Manchester mayor nicknamed "King of the North", won the contest in Makerfield in northwest England with 54.8 per cent of the vote, beating the candidate for Nigel Farage's populist Reform UK party, on 34.5 per cent.
The scale of Burnham's victory in what could be the most consequential by-election in more than six decades puts him in a strong position to challenge Starmer, struggling with some of the worst popularity ratings of any British leader.
Burnham indicated he wanted to counter the rise of polarising, populist politics, saying his victory was a chance to turn "away from the path that takes us to a divided, dark politics of the kind we see in the United States".
Attention now turns to the timing of his move, and whether he can convince the prime minister to relinquish power without a potentially disruptive leadership contest.
In his victory speech, Burnham said the result could be a "turning point".
"We must hear it, we must act upon it, and we must get it right," he said early on Friday.
"There will be no second chance."
Starmer, who has said he will fight on, quickly congratulated Burnham, saying on X: "Voters chose Labour's campaign of hope and optimism over division and hate."
Burnham, a 56-year-old career politician who has backed the nationalisation of key public services and criticised what he called four decades of failed neo-liberal economics, has said he would stand in any contest to replace Starmer.
Polls indicate he would win a leadership contest decided by party members, although some Labour MPs hope that process can be avoided.
That would mean Britain installing its seventh prime minister in just more than a decade, the highest turnover in nearly two centuries - a reflection of voter anger at successive failures to improve living standards and public services and tackle illegal immigration.
Two years after a landslide national election victory, Starmer, 63, is one of the least popular British premiers since polling records began.
Scandals, policy U-turns and accusations of indecision have derailed delivery of the change he once promised.
About a quarter of his MPs have urged him to quit since Labour suffered heavy losses in local elections in May.
Senior colleagues, including the defence and health ministers, have resigned over his leadership.
Starmer insists he will stand in any leadership contest and has warned his party about the dangers of a potentially divisive leadership campaign.
But several Labour MPs said the scale of Burnham's win would force Starmer to consider stepping aside.
Culture minister Lisa Nandy, a prominent Burnham ally, told reporters she expected both men to speak soon.
She ruled out quitting the cabinet but said she could not speak for others.
Burnham will return to London, the heart of government, with the credentials of someone who can defeat the insurgent Reform party, said one Labour MP.
Many Labour members of parliament fear losing their seats in the next election, due in 2029, to Farage's party, which leads opinion polls.
Another of Starmer's rivals, former health minister Wes Streeting, said this week he would force a contest soon unless the prime minister announced when he would stand down.
He said Burnham's victory was proof that Labour needed to change.
Party rules require 20 per cent of the parliamentary party, or 81 MPs, to announce they are backing a single candidate to trigger a leadership challenge.