Adil Rashid was the ninth England wicket to fall, run out at the beginning of the 49th over

One-day international, Edinburgh: Scotland 371-5 (50 overs): MacLeod 140* (94), Coetzer 58 (49) England 365 (48.5 overs): Bairstow 105 (59), Watt 3-55 Scotland won by six runs Scorecard

Scotland secured the biggest win in their cricketing history with a thrilling six-run defeat of England.

Callum MacLeod's brilliant 140 not out took the home side to 371-5 in glorious batting conditions in Edinburgh.

Jonny Bairstow's 54-ball century looked to have England on course until they slipped from 220-2 to 276-7.

Liam Plunkett (47 not out) and Moeen Ali (46) kept them in it, but last man Mark Wood was lbw to Safyaan Sharif from the fifth ball of the 49th over.

It is a wonderful result for Scotland, who have been improving steadily since the 2015 World Cup and were only denied a place in the 2019 tournament when rain stopped their match against West Indies in the qualifying tournament in March.

Here, against the number one ranked side in the world, the Scots gave the sort of performance that further questions the International Cricket Council's decision to cut the World Cup to only 10 teams.

For England, so impressive in limited-overs cricket in recent years, this first defeat by Scotland can be mentioned in the same breath as the Twenty20 humblings by the Netherlands, and World Cup losses to Ireland and Bangladesh.

They must regroup for the five-match series against Australia, which begins at The Oval on Wednesday, while Scotland move on to T20s against Pakistan on Tuesday and Wednesday.

England humbled by superb Scotland

This was a magnificent occasion at the picturesque Grange ground, with a flat pitch surrounded by small boundaries and a lightning outfield.

England's attack, without the injured Ben Stokes and Chris Woakes, looked toothless, but that is to take nothing from the impressive batting of the Scots.

Any suggestion England were incapable of pulling off their highest ODI chase was dispelled by a Bairstow innings that silenced the partisan crowd.

But England engineered their own downfall, first after Bairstow skewed to long-off, then by gifting wickets away in a middle-order collapse of five for 56.

Still, Moeen and Plunkett remained calm in a tense atmosphere in which every dot ball was cheered.

Then came the final twist. Moeen holed out to long-on, Adil Rashid was run out coming back for a second and Wood pinned by a Sharif yorker to spark joyous scenes and a celebratory pitch invasion.

MacLeod magic propels Scotland

Calum MacLeod hit the fastest century by a Scotland batsman in ODIs

Right-hander MacLeod was released by Durham at end of the 2016 season and now plays for Bexley; last Saturday he made 78 against Lordswood in the Kent Premier League.

He arrived at number three after openers Kyle Coetzer and Matthew Cross shared 103 in 13 overs, taking advantage of some indifferent new-ball bowling.

MacLeod had only 11 from the first 14 balls he faced, but built by sweeping the spin of Moeen and Rashid - he went to 50 from 36 balls with a swept six off Moeen.

The 29-year-old added 93 for the third wicket with Richie Berrington and 107 for the fourth with George Munsey. When he nudged Rashid into the leg side, he become the first Scotland batsman to make a century against England, his 70-ball ton the fastest by a Scot in ODIs.

He helped the home side take 105 from the final 10 overs, sharing 53 for the fifth wicket with debutant Dylan Budge, who contributed only 11.

By the time MacLeod was done, his 94-ball stay had yielded 16 fours and three sixes but, more importantly, had set Scotland on their way to a historic victory.

Bairstow brilliance not enough for England

Bairstow's 54-ball century is the third-fastest by an England player in ODIs

For as long as the powerful Bairstow was the crease, it seemed England would overhaul their huge target with plenty of time to spare.

Crashing the ball through the covers or heaving over the leg side, he became the first England batsman to hit three successive one-day centuries.

After he departed to the medium-pace of Berrington, the chase was being marshalled by Alex Hales and Joe Root.

But, Hales' call left Root unable to make his ground at the non-striker's end and, after that, Hales, Eoin Morgan, Sam Billings and David Willey fell to loose strokes.

England needed 96 from 81 deliveries with only three wickets in hand when Plunkett arrived to support Moeen, an equation that came down to 26 from 30 when Berrington was taken for 18 in the 45th over.

Scotland, though, held their nerve. Moeen needlessly found long-on, Michael Leask's deadly throw from the deep beat Rashid's dive and Sharif's inswinging yorker was too much for number 11 Wood.

'We've created an electric atmosphere' - what they said

Scotland captain Kyle Coetzer told BBC Sport: "It means a lot to the guys. We've created an electric atmosphere and it's something we need to do more. It was an outstanding game and the guys did unbelievably well to knock over the number one side in the world.

"It was nice to see what this Scottish team can really provide. It would be nice to play a few more games like this. It's nice for us to take this opportunity."

England captain Eoin Morgan told BBC Sport: "It was a fantastic game of cricket. Scotland played extremely well. They brought their best game and we didn't, we were far from it. Full credit to Scotland. Today was a really good run out. Usually, leading into a series we have a few days of training, then straight into it. Today was outstanding, to make mistakes, hopefully we can learn from them going into Wednesday."

Former England batsman James Taylor on TMS: "A lot of credit has to go to how Scotland performed. They were dominant, they made partnerships, ran well and scoring 371 was a brilliant effort. Every time England got on top they let Scotland back into the game, whether it was poor run outs, poor choices."

Former Scotland pace bowler Dougie Brown on TMS: "That was a magnificent game of cricket - 6,000 very happy people probably didn't expect to go home having seen something like this. If you're England, you might rather lose this game than the first game of a series against Australia."