Scotland survived a nail-biting final round-robin match to beat Switzerland and qualify for the World Men's Curling Championship play-offs in Las Vegas.
Ross Paterson's rink had to win having after losing three matches in a row.
But, hours after losing 8-6 to leaders Canada at the final end, the Scots did the same to beat the Swiss 9-7.
It means the Scots face United States in Saturday's play-off for the right to set up a re-match with Brad Gushue's Canadians in the semi-finals.
Canada won 10 of their 12 round-robin games on their way to topping the standings ahead of Sweden's reigning world and Olympic champions.
Five-times champion Niklas Edin's team await the winners of the play-off between Joel Retornaz's Italians, who finished third in the round robin, and Yannick Schwaller's Swiss, who finished sixth.
A shock 5-4 loss on Thursday to Netherlands, who finished second bottom, before an 8-2 defeat by Sweden had put pressure on Patterson's rink going into the final day of the round robin.
The Scots scored a double at the ninth end to tie at 6-6 with the already qualified Canadians, but Gushue took two at the last to secure victory.
Paterson's rink raced into a 5-0 lead after four ends against the Swiss, but their opponents picked up three shots at both the seventh and ninth ends to lie 8-7 down going into the final end before the Scots secured a seventh win of the week and fourth place in the table.
Scotland skip Kyle Waddell said: "I thought we played really well. To be fair to them, they played a really good end in seven. We tried not to be too worried.
"I'm really happy with where we're at, especially after the bad day yesterday, when we felt we didn't do ourselves justice."
Korey Dropkin's hosts face the Scots after losing their final round-robin game 8-4 to Italy and finish on seven wins along with Saturday's play-off opponents.