Scotland saw off Fiji 28-12 at Murrayfield on Saturday in unconvincing fashion as they revived their Autumn Nations Series campaign.
George Turner's try gave Scotland an early lead but the visitors, coached by former Scotland boss Vern Cotter, hit back with two of their own before the hosts managed to lead 14-12 at the interval.
Tries either side of half-time from Adam Hastings and Duhan van der Merwe gave Scotland breathing space before replacement Ben White crossed late on.
Victory came after Scotland started their end-of-year programme with a 16-15 loss to Australia at Murrayfield last weekend.
But a double-figure penalty count against Fiji was a worrying sign for Scotland coach Gregor Townsend ahead of New Zealand's visit a week on Sunday, with the Scots yet to beat the All Blacks in 31 matches spanning 117 years.
- 'Found a way to win' -
"Relatively pleased," Townsend told Amazon Prime when asked for his assessment of the game.
"We gave away too many penalties in that first half, which gave Fiji confidence and points on the board. Second half we stuck about our task, we could've got more points, but we found a way to win which is important."
The former Scotland playmaker added: "We've never beaten (New Zealand) in our history... We'll have to be much better, we know that."
Fiji suffered an early setback on Saturday when debutant Ratu Rotuisolia was sin-binned.
Scotland made their advantage count when Turner pushed his way over from a rolling maul for a seventh-minute try.
Hastings, given the chance to stake a claim to the No 10 shirt in the absence of both Finn Russell and Blair Kinghorn, added the conversion.
Fiji's Setareki Tuicuvu missed a routine penalty only to atone minutes later when he crowned a flowing attack out on the right with a try before failing with the conversion.
The Pacific islanders, however, were playing with confidence and Rotuisolia -- back on after his yellow card -- put them ahead with a well-taken try in the 23rd minute.
To make matters worse for Scotland, Stuart Hogg was sin-binned as he paid the price for repeated offending by the home side.
Vilimoni Botitu, taking over kicking duties, added the conversion and Fiji led 12-7.
Scotland, however, avoided conceding any more points while down to 14 men.
And the last play of the first half saw Scotland scrum-half Ali Price release Hastings, the son of Scotland great Gavin Hastings, who then elegantly broke free to score a try he converted to put the Dark Blues two points ahead at the break.
It was Hastings' last significant contribution to the match, the Gloucester No 10 leaving the field early in the second half with a head injury.
Scotland extended their lead when dashing wing Van der Merwe held a looping pass from Chris Harris before beating two Fijians for a try.
Replacement back Kinghorn, who missed a last-gasp penalty that would have won the Australia match, landed a tough conversion from out on the left.
Fiji's Vinaya Habosi was sin-binned in the 61st minute for a high tackle on Scotland replacement Rory Sutherland and Livai Natave also saw yellow after Cameron Redpath was denied a 73rd minute try following a knock-on.
Moments later, however, Scotland had a fourth try when White darted over from the back of a scrum.