After Jonny Bairstow’s earlier century, England looked like they were creeping towards victory thanks to a 71-run eighth-wicket partnership between Moeen Ali and Liam Plunkett.
However, the hosts held their nerve to pick up the remaining three wickets and an emotional victory.
It is the first time Scotland have beaten England in international cricket, and it came in their first game since being cruelly denied a place in next year’s World Cup.
Scotland were out to prove a point after the decision was made to cut down the number of participating nations from 14 to 10, making it harder for associate nations to compete and grow the game – and they showed they can compete with the best by seeing off the world’s top 50-over side in stunning fashion.
It is an embarrassing defeat for England just a year before the World Cup they have clearly set their sights on winning – but they could have no complaints after conceding 371 to Scotland, the hosts’ highest score in ODI cricket.
There was further history made with Bairstow’s century his third in a row – the first time an English batsman has done that – but his 54-ball effort was in vain as England came up short.
The target was set after Kyle Coetzer and Matthew Cross had laid the foundations with an opening partnership of 103, which set the tone for the rest of the day after being put in to bat.
The pair fell in quick succession, but that only brought Calum MacLeod to the crease and the former Durham batsman proved the mainstay throughout the innings as he smashed his seventh ODI ton.
He had support from George Munsey (55) but his unbeaten 140 from 90 balls was the standout knock of the match and proved too much for England, despite a promising start to the reply.
Jason Roy and Bairstow looked like making a mockery of the total by racing past 100 in the opening 10 overs, but once Roy fell England were unable to put together any substantial partnerships as wickets fell at regular intervals.
Bairstow was brilliant for his 105 but he holed out when he could have gone on and made the game safe, and after Alex Hales and Eoin Morgan fell in successive balls, England looked well up against it.
David Willey and Sam Billings also fell cheaply as the visitors slipped to 276 for seven, before Moeen and Plunkett combined to breath life back into the contest.
They were going along at a good rate and the crowd had finally been quietened when Moeen chipped to long-off to revive Scottish hopes, then Adil Rashid was run out as nerves began to get the better of the batsmen.
Sharif then trapped Wood dead in front of the stumps to clinch an emotional victory for the Scotland players.