Edmund, from Beverley, who had conquered Novak Djokovic and David Goffin in the previous rounds, lost his cool towards the end of a tight second set when he stopped after a spectator called out, and Shapovalov proceeded to serve an ace.
The incident temporarily affected Edmund, who had to subsequently save a match point to force a deciding set, in which he eventually fell to exit the tournament 7-5 6-7 (6/8) 6-4.
Edmund had acquitted himself against a player rated as one of the game’s rising stars, swapping breaks early in the first set before a sloppy final service game saw the British number one fall behind.
A tight second set burst into life in the 10th game after the incident which saw Edmund engage in a furious exchange with the umpire over a point he considered could have cost him the match.
But Edmund showed admirable poise to edge through the eventual second set tie-break before Shapovalov grabbed what turned out to be the crucial break in the third game of the decider.
Nevertheless the 23-year-old Edmund gave his all in what was his first Masters 1000 quarter-final, and he can expect to be rewarded with a place in the top 20 for the first time when the new rankings appear on Monday.
Elsewhere, Rafael Nadal lost his long unbeaten streak on clay and his world No 1 ranking after a shock defeat to Dominic Thiem in the quarter-finals.
The Spaniard had surpassed John McEnroe’s record for 50 straight-set wins on a single surface when he eased through to the last eight of the event on Thursday.
But Nadal could not maintain his form and went down 7-5 6-3 to the Austrian No 7, who broke his opponent’s serve five times in the two-hour match.
As a result of Nadal’s defeat, Roger Federer, who is sitting out the clay-court season, will return to world No 1 on Monday, but Nadal could regain top spot with a win in Rome.
Maria Sharapova’s encouraging run at the Madrid Open came to an end when she was beaten by Kiki Bertens at the quarter-final stage.
Having made her first major quarter-final since returning from a drugs ban, Sharapova looked in good shape to extend her run when she took the first set 6-4.
But big-hitting Bertens, a former French Open semi-finalist, hit back to win 3-6 6-2 6-3, leaving Sharapova to acknowledge she still has improvements to make.