EDINBURGH, Scotland (AP) — Scotland needed a record score against Samoa to edge the Pacific island side 44-38 at a packed Murrayfield on Saturday.

The Scots, the overwhelming favorite, squandered a 32-10 lead with half an hour to go with poor defense around the rucks.

"We weren't able to slow down their ball enough in the second half," Gregor Townsend said after his first home match as coach. "We did that well in the first half, when we got a few turnovers to play off, but in the second half they were getting momentum."

To the credit of Manu Samoa, in a week in which their oft-criticized administrators declared their union bankrupt, they never gave up. They didn't threaten to win their first test this year, but they made Scotland extremely uncomfortable.

Scotland split its six tries evenly in each half, but just when each second-half try seemed to herald safety, the Samoans replied within three minutes each time with a try of their own. The Samoans finished with five, their highest score against Scotland, and their highest score anywhere in more than four years.

"I felt like even though the result didn't go our way, it almost put us back on the map," Samoa captain Chris Vui said. "We're a really proud country and we're here to play rugby."

After hooker Stuart McInally's second try from a rolling maul made it 32-10, Scotland appeared supreme. It wasn't dominating possession or territory but using lineouts effectively, turning over ruck ball, and taking its chances in the 22. It had the confidence to debut three reserves, with starting prop Darryl Marfo.

But within three minutes, Scotland's close-in defense was shown up again as Samoa flanker Piula Fa'asalele crossed after several pick-and-goes.

When Tim Nanai-Williams, usually a fullback but playing flyhalf for the first time like a veteran, angled off ruck ball and sped in, Samoa cut the gap to eight with less than a quarter to go.

When Alex Dunbar crashed over between two Samoans, Samoa hit straight back through counterpart Kieron Fonotia, and was only six behind.

When replacement Pete Horne finished a counterattack launched by fullback Stuart Hogg with six minutes left, Scotland looked safe once more. But Samoa hit back quickly again, replacement flanker Ofisa Treviranus running in untouched from a ruck with three minutes to go.

Nanai-Williams' fifth conversion gave him a match tally of 18 points.

In the end, fulltime came as a relief for Scotland, even though it surpassed its previous highest score against Samoa, 38 in 2004 in Wellington.

Scotland began not only with home advantage and a sell-out crowd of 67,000 but also cohesion: Five Edinburgh players in the pack and an all-Glasgow backline. The knowledge showed in the first half. Scotland scored after only 94 seconds, when a Finn Russell grubber-kick was chipped on by wing Tommy Seymour and the ball bounced kindly for Hogg to pouch and score.

Samoa lock Josh Tyrell scored a try on debut between the posts from a quick-tap.

Then Scotland prop WP Nel walked off with a suspected broken forearm, and his teammates finished the half in a rush. Hogg set up center Huw Jones to score in the left corner, and McInally scored in injury time from a lineout drive.

It all looked promising for Scotland. But the defense withered.

And the All Blacks come next week.