Ben Stokes has been crowned BBC Sports Personality of the Year after playing a key role in the team's World Cup win and producing one of England's most remarkable Test innings of all time against Australia at Headingley.

England's World Cup side were also recognised in the team of the year category, while Jos Buttler's run-out of Martin Guptill to seal the trophy in the final against New Zealand was voted moment of the year as cricket sealed a treble victory.

Stokes' nearest rivals were Lewis Hamilton, the Formula One driver, who came second, and Dina Asher-Smith, the sprinter, in third. His win ends a barren run for cricketers in the award, as he becomes the first to win the prize since Freddie Flintoff in 2005. Stokes is the fifth player to have claimed the title since its inception in 1954, following Jim Laker (1956), David Steele (1975), Ian Botham (1981) and Flintoff.

"It's an individual award, but I play in a team sport," said Stokes. "The best thing about that is you get to share special moments with team-mates, backroom staff, management who make days like we had in the summer possible. I'm up here receiving this award not just by myself but without the efforts that you put in this summer, I wouldn't be up here doing that.

"Two years ago was a tough time for me in my life. I've had so many people help me through that. Family to me is more important to me than what I do for a living... I come home from a good day or a bad day and they're there for me no matter what."

The allrounder's win will be seen a significant boost for cricket's standing in England, not least given that not a single player had even managed a podium finish since the game went behind the paywall following the 2005 Ashes.

While the sight of Andy Murray receiving the award poolside while in Miami has become a regular one in recent years - Flintoff himself heard the news of his victory in a Lahore hotel at 3am in 2005 - the ECB allowed Stokes to attend the ceremony in Aberdeen, despite the fact that the rest of the Test squad departed to South Africa on Friday evening.

Stokes' attendance at the prizegiving means that he will miss England's first two-day warmup match in Benoni which starts on Tuesday, but that was seen as a price worth paying for the ECB as they attempt to return the game to public consciousness ahead of its return to free-to-air television next summer.

"It's been huge," said Jason Roy - who attended the ceremony alongside white-ball captain Eoin Morgan - of the World Cup win's significance for the game's public standing. "For us to work so hard for the four years and for it to come down to that moment, and to wake up the following day and keep getting messages... to inspire people like we did was incredible."

Ashley Giles, England's managing director, said: "I'm so pleased for Ben. His exploits this summer showed he is one of the finest cricketers in the world. I played alongside Andrew Flintoff when he won the award in 2005 and Ben's feats this year place him in the same bracket as Freddie, and Ian Botham before him."

Tom Harrison, the ECB's CEO, said that the award "confirms [Stokes'] place in the hearts of the British public".

"It's wonderful news that Ben has been named the winner of Sports Personality of the Year," Harrison said. "This is richly deserved and it puts the finishing touch to an amazing year for Ben and for English cricket. He is not just one of the greatest cricketers we have ever had, but someone who has shown what it means to face into adversity and come through it.

"We're also thrilled that the England team who won the men's World Cup for the first time have been honoured too. No-one who was at Lord's on July 14 will ever forget that extraordinarily dramatic win over New Zealand."

Earlier in the evening, host Gary Lineker had mistakenly introduced Stokes as the "main award winner" rather than "nominee" before the public vote had even opened, perhaps reflecting the fact that the allrounder was the odds-on favourite with the bookmakers.

The rest of England's Test squad watched the show from their hotel in Johannesburg, and were part of a huge social media push from the English cricketing world encouraging people to vote.

Steve Smith's 774 runs in seven Ashes innings earned him a nomination in the World Sport Star category, but he was beaten by Kenyan marathon runner Eliud Kipchoge.