The hosts were trailing 28-25 with three minutes to go and earned a penalty in the Canada 22, but captain Lisa Thomson missed the kick and the chance of a draw had gone.
Given that Scotland came into this match on the back of a 38-0 defeat in Italy at the start of the month while Canada are in the top four in the world, the visitors started as favourites.
The Scots had clearly been working hard on their game shape and aggression at the breakdown in recent weeks though because they looked a different side in this one.
Head coach Shade Munro, pictured, said: “That has to be our standard going forward, it is one that perhaps got away, but the girls played very well.”
Scotland took the lead in the opening two minutes when they won a penalty and centre Helen Nelson kicked it over from some distance.
Canada responded soon after, second-row Tyson Beukeboom going over for the try. Scrum-half Brianna Miller converted to make it 7-3 after five minutes.
Scotland had some good phases of play and Nelson had a couple of half breaks, but they were struggling to make headway.
And just after the first quarter of the match had passed the visitors scored their second try, centre Tausani Levale going over. Miller again converted.
The hosts got themselves right back into things in the 33rd minute when they scored a well-worked try through winger Abi Evans, the ball having been shipped left quickly and she finished sharply.
Nelson could not convert and was then forced off with injury, but the Scots scored again just before half-time.
A lineout was taken at the tail by tighthead prop Megan Kennedy and, after she had gone close, No 8 Jade Konkel powered her way over. Stand-off Lisa Martin converted and it was 15-14 to the Scots at the break.
Beukeboom got her second try of the day in the 44th minute for Canada, full-back Irene Patrinos converted and it was 21-15.
Scotland were still mixing it with their opponents though and, with winger Bryony Nelson now on for a first cap, they scored their third try in the 56th minute. It came through centre Thomson, but Martin could not convert.
Just before the hour mark Canada scored their fourth try through back-row Janna Slevinsky which Patrinos converted to leave things at 28-20 to the visitors.
With 17 minutes to go in this end-to-end clash Scotland closed the gap to three points when second-row Emma Wassell went over from close range.
Martin’s conversion missed, but with seven minutes to go the Scots nearly went ahead again.
A great break by full-back Chloe Rollie got them close to the line and then, as Konkel was diving over the line to score the ball was knocked from her hands by opposite number Cindy Nelles.
And four minutes later Thomson’s penalty was skewed wide and the much improved Scots were left to wonder what might have been.