Stuart Hogg became Scotland's leading try scorer as they earned a third Autumn Nations Series win in four by edging past Japan at Murrayfield.
Hogg, in his 88th Test, burst over for his 25th try to beat the record set in the 1930s by Ian Smith and restore the lead earned by Duhan van Der Merwe's early score.
Darcy Graham gave the hosts an interval cushion and, although Rikiya Matsuda's boot and a Tevita Tatafu effort kept Japan in touch, Stuart McInally's try ultimately proved enough for Scotland.
The victory added to successes over Tonga and Australia, as Gregor Townsend's side followed up defeat by world champions South Africa with this unconvincing win over their troublesome visitors.
Every Scotland fan will suffer some kind of anxiety attack whenever Japan are the opposition, those World Cup memories from Yokohama in 2019 still vivid enough even though so much has changed for both sides in the meantime.
The Scots have advanced, the Japanese, starved of meaningful games and proper vision among those running the game, have regressed, though they made life uncomfortable here.
Scotland put in a mundane show, littered with errors and the kind of things that will have brought on a quiet seethe in Townsend.
Big players step up amid patchy performance
Scotland were accurate only in patches and one came early. They had a penalty in front of the posts but went for touch instead. Eventually, Van der Merwe forced his way for his ninth try in 13 Tests.
This was a struggle at times, though. Once again Scotland's discipline was awfully poor - they conceded 15 penalties against the Boks last week and another six in the first 25 minutes here - and the line-out was not exactly pin sharp either. They coughed up two early throws.
Matsuda put some deserved points on the board for Japan and added another three soon after when Scotland were done again at the breakdown.
Their 6-5 lead was warranted, but it was short-lived. When Scotland desperately needed somebody to put a fire under them - and the hushed crowd - it was Hogg, not for the first time, who did it.
His break, a skipping and stepping thing of beauty, put Scotland on the front foot in the first place. As Japan scrambled, the hosts capitalised.
They needed a few recycles to find the space but when they did it was Russell who fed Hogg to gallop over for his record-busting score. A 25th try for his country - what a haul, what a player. Russell's conversion was good.
Scotland's third score came before the break. Russell put in a poor kick, which was fumbled ridiculously, and the home side had a scrum. The fly-half then came on a screaming left to right run.
Graham got it and cut in off his wing to beat a Japanese defence who were not wise to his footwork. That is 10 tries in 22 Tests for him. The conversion made it 19-6 at the break.
Scotland see it out, but work to do
Scotland had only been fleetingly impressive. They had taken their tries well but had been average at best and their woes returned early in the new half when their inability to stay on the right side of the referee cost them points and a man in the bin.
Jamie Bhatti walked for another breakdown infringement and Matsuda put over the penalty that came with it. Then he put over another as Scotland lost their way once more. A comfortable 19-6 lead had turned into a ropey 19-12 advantage.
As soon as they were restored to 15, Scotland scored again, though. McInally got on the end of a line-out maul and nobody was stopping him.
Russell's conversion made it a 14-point game but Scotland's vulnerability was exposed again when, off a line3-out, Tatafu blasted through Hamish Watson and Javan Sebastian - on for his debut - to narrow the gap to nine.
Matsuda messed up the extras, but the try gave Japan momentum and hope. And yet another Scotland penalty - the count was sky high by now - gave Matsuda a chance to make amends, which he did.
With eight minutes to go it was now a six-point game, but Scotland saw it out from there.
They put it beyond Japan's reach with a late Russell penalty that secured their third win from four this autumn. A good return but on this evidence they have serious amounts of work to do if they want to get in the shake-up in the Six Nations.
These Tests were just the warm-up act. The big show is on its way.
'You can see how much it meant' - reaction
Scotland captain Stuart Hogg: "I think you can see by my reaction how much it [the new record] meant to me. The main thing, though, is we got a good win.
"We've managed to win three out of four Test matches in the autumn and the exciting thing for me is that we're not quite satisfied with everything that happened.
"We're yet to find that complete 80-minute performance but I think part of that was because we were put under a lot of pressure by Japan who managed to hold on to the ball for large periods."
Scotland head coach Gregor Townsend: "It was a real Test match. Japan showed the level of play we saw from them in 2019. They're the only team I can think of in world rugby who keep the ball in their own half and go through the phases.
"I've got to commend our defensive effort. We had to come through adversity too, with penalties against us and the yellow card. I felt our contact work in attack was the best it's been in the whole campaign."
Scotland: Hogg, Graham, Harris, Johnson, Van der Merwe, Russell, Price; Bhatti, Turner, Z Fagerson, Cummings, Gilchrist, Ritchie, Watson, Bayliss.
Replacements: McInally, Schoeman, Sebastian, Skinner, Richardson, M Fagerson, Horne, Kinghorn.
Japan: Yamanaka, Matsushima, Nakono, Nakamura, Fifita, Matsuda, Nagare; Millar, Sakate, Ai Valu, Cornelsen, Moore, Leitch, Labuschagne, Himeno.
Replacements: Horikoshi, Inagaki, Kakinaga, Gunter, Tatafu, Saito, Tamura, Reily.
Referee: Brendan Pickerill (NZ)