Danny Care scored a late try to give England an 18-17 win over a superb Samoa, after the Pacific islanders looked on course for a first victory against an opponent already assured of their World Cup quarter-final berth.
Two tries from winger Nigel Ah-Wong had Samoa leading deep into the match on Saturday (local time), but replacement halfback Care slipped through from the back of a scrum seven minutes from time and Owen Farrell converted to complete the win.
England finished on 18 points. Argentina and Japan, both on nine, meet on Sunday in a shootout for a quarter-final place. Samoa ended on seven, ahead of Chile on zero.
A performance littered with errors was summed up by captain Farrell becoming the first player at the tournament to be timed out by the shot clock as he exceeded the 60-second limit for a straightforward penalty with England trailing by six points.
"It was scrappy, it did not feel like the best from us," said Farrell.
"All credit to Samoa and how they came out and got at us, it was tough to deal with at times and we did not deal with it discipline-wise and with mistakes. But I'm happy we found a way to win."
Coach Steve Borthwick also praised the Samoans.
"Looking ahead to next week, we wanted a tough test and we got it. But these players, who have been criticised in the past for not doing it, found a way to get the result."
It had started well for England who struck after nine minutes with one of their best tries of the tournament. A fizzing pass by Farrell sent Freddie Steward and Manu Tuilagi clear before lock Ollie Chessum as an unlikely winger finished it off.
Farrell missed the conversion but landed a penalty to overtake Jonny Wilkinson as England’s leading scorer, with 1,181 points and give his side an 8-0 lead.
AGONISINGLY CLOSE
Samoa hit back quickly, working Ah-Wong over in the corner for only the second try England have conceded at the tournament.
That soon became three as Danny Toala launched a superb crossfield kick that Ah-Wong collected and showed amazing dexterity to touch down as he flew beyond the in-goal zone.
England were wretched in thought and deed and a poor kick by Alex Mitchell appeared to gift Duncan Paia'aua a third try, only for the TMO to spot a knock-on and rule it out.
It was a lucky escape for England, who were fortunate to reach halftime only 14-8 down.
Samoa, seeking their first win over England at the ninth attempt, had the slimmest chance of reaching the quarter-finals but knew victory would have given them a fighting opportunity of securing qualification for the 2027 tournament, and it looked on when another penalty put them 17-8 ahead.
England coach Steve Borthwick acted after 51 minutes, bringing Marcus Smith on for George Ford, with Farrell moving to first five-eighth.
The 2019 runners-up quickly regained control, though tries by Chessum and Joe Marchant were ruled out. Farrell landed a penalty but, from right in front of the posts, was timed out with another.
A tiring Samoa had Tumua Manu sin-binned for an illegal aerial challenge and Care darted over for a try that Farrell converted.
Samoa came agonisingly close to winning the game in the final minute with a sparkling attack that was foiled metres short by a tackle from Care.
"That was a tough one, my heart breaks for these boys," said Samoa coach Seilala Mapusua. "I thought we did enough to earn a victory - but that's the cruel nature of sport."