NEWCASTLE, England -- Scotland reached the Rugby World Cup quarterfinals by beating Samoa 36-33 in a thrilling Pool B game on Saturday, denying Japan a last-gasp shot at advancing to the knockout stage for the first time.

The Scots settled after a wild first half in which they conceded three tries and their defensive line was broken at will by the Pacific Islanders, who led 26-23 at the break.

However, the Samoans couldn't keep up their dazzling play and Scotland ground them down in the forwards, allowing scrumhalf Greig Laidlaw to kick two penalties and then cross for the clinching try in the 74th minute.

A late, fourth Samoa try made for a tense last two minutes, but the party had already started among Scottish fans who crossed the border to turn St. James' Park into a sea of dark blue.

In the 2011 tournament, Scotland failed to advance from the group for the first time and players vowed to make amends four years on.

"It's a great day for Scottish rugby," said Laidlaw, who finished with 26 points. "There's more to come, we believe, from this Scotland team."

The Scots placed second in the pool, behind South Africa, and will play the winner of the Australia vs. Wales match later Saturday at Twickenham.

The Samoans played for pride in Newcastle, with their campaign effectively over after losing 26-5 to Japan last weekend. Their discipline has been poor in this tournament -- and they conceded 19 penalties here -- but they remained a danger because of the quality of the strike runners in their backs, and Scotland couldn't cope in a dramatic first half of end-to-end action.

"They were very good with the ball," Scotland coach Vern Cotter said. "We had anticipated they'd go to more of a Barbarian style, but it wasn't really because they were very physical -- probably one of the most physical games we've had. But we stayed in there."

Inside centre Reynold Lee-Lo, especially, found holes out wide and ran for 120 metres. He set up Samoa's first try for Tusi Pisi in the right corner and scored the team's third in an inspired performance.

But indiscipline led to the demise of Manu Samoa. Scotland replied immediately to Pisi's try when winger Tommy Seymour intercepted a wild, cut-out pass from Pisi near his own posts, moments after the restart.

And Scotland fed off a string of Samoa penalties at the breakdown, with Laidlaw's kicking and John Hardie's try at the base of a rolling maul keeping Scotland to within three points at halftime. Samoa should have been much further ahead, having dominated territory and possession.

"Our strategy was pretty simple -- go out there, have some fun, and bring some pride back with Samoan-rugby style," Samoa captain Kahn Fotuali'i said. "We had to muscle up, be direct and get back some enjoyment in the way we played as islanders."

The second half was completely different as both defences tightened up, but Scotland forced more penalties out of Samoa, and Laidlaw kicked two from four shots at goal, giving them the lead for the first time in the 54th.

With six minutes left, Laidlaw opted against a kick at goal and went for an attacking scrum. The bold choice paid off, as he collected the ball, dummied, and sniped over near the posts for a converted try that cut off Samoan -- and Japanese -- hopes.

"We came across a Samoa team we haven't seen in this World Cup," Cotter said. "They were impressive and we had to change the way weplayed. We adapted and got there in the end, so we're really really happy."