Samoa (12) 15
Samoa (top) went into the game as favourites but played very poorly
Pens: Williams 5
Tonga (6) 19
Pens: Hola 4
Tonga shocked Pacific Island neighbours Samoa to throw the race for Pool A qualification wide open.
Four penalties from Gavin Williams gave Samoa a 12-6 half-time lead.
But an Epi Taione try and five points from Pierre Hola, who had kicked two first-half penalties, put them 19-12 up in Montpellier.
A fourth Williams penalty trimmed the gap but Tonga held on to consolidate their second place in the group despite despite losing two men late on.
Samoa, who are England's next opponents on 22 September, had been expected to provide the greatest threat to the floundering world champions' hopes of reaching the quarter-finals.
But this result means England must now be dreading their meeting with Tonga, who beat USA in their opening game, on 28 September in Paris as well.
Tonga and Samoa have a reputation for being among the two most explosive sides in the world game but anyone expecting a pulsating opening to the encounter was to be disappointed.
Samoa had battered South Africa for 40 minutes in their opening match in France before running out of steam in the second half.
But they started slowly against Tonga, who drew first blood through Hola's penalty.
Samoa soon hit back through a penalty from Williams, the son of former New Zealand legend Brian, and were also denied a try when the televison match official ruled out a score from Elvis Seveali'i.
Samoa's territorial advantage led to two more Williams penalties, the second after a trademark charge from powerhouse Leicester winger Alesana Tuilagi.
When Tonga saw former Newcastle and Sale player Taione sin-binned after yet another infringement at a ruck, a fourth Williams penalty made it 12-3 after 28 minutes.
Toulouse flanker Finau Maka excelled for Tonga
Tonga, ranked four places below Samoa, reduced the deficit through a second Hola penalty as the half ended 12-6.
Hola then added another three points before Tonga took the lead when Taione finished off a powerful forward drive.
Hola converted to make it 16-12 before edging his side further ahead with a fourth penalty.
Hale T Pole conceded a silly penalty to enable Williams to trim the gap to four points.
And the Tongan blind-side then put his side in deep trouble as he was red-carded following a forearm smash to the face of a Samoan with nine minutes to go.
Things went from bad to worse for Tonga as replacement Toma Toke was shown a yellow card for a high tackle to reduce the Sea Eagles to 13 men.
But Samoa could not take advantage as Tonga produced a series of big hits in defence to claim a shock victory.
Samoa coach Michael Jones:
"It was very disappointing. We know we are a better side than how we played, especially in the second half.
"The biggest disappointment for us was we made too many unforced errors and we didn't have the mental toughness to push through when they had men down in the last few minutes.
"At the end of day we were beaten by a team that was much hungrier and that hurts us to say that because we normally pride ourselves on our passion and desire.
"We were out-passioned and out-muscled by a very, very good Tongan team. We acknowledge that. They were awesome."
Tonga coach Quddus Fielea:
"I think when we went down to 13, no-one realised that we had a big prayer this morning before the game. That was the secret of the whole thing.
"Normally back at home Sunday is a rest day, but we had this draw to play on Sunday and so we had a prayer instead.
"I'm not really in a position to rate this victory, that will be up to the rugby community at home, but I would say it is one of the tops, to win two games in the World Cup is a major achievement."
Samoa: Williams; Tagicakibau, Seveali'i, Mapusua, A Tuilagi; Crichton, So'oialo; Va'a, Schwalger, Johnston, Tekori, Thompson, Leo, Ulia, Sititi (capt).
Replacements: Fuga, Salanoa, Lafaiali'I, Purdie, Polu, Lui, Lemi.
Tonga: Lilo; Tu'ifua, Hufanga, Taione, Vaka; Hola, Taufa; Tonga'uiha, Taukafa, Pulu, Afeaki, Hehea, Pole, Latu (capt), Maka.
Replacements: Lutui, Toke, Vaki, Kauhenga, Tu'ipulotu, Tupou, Tonga'uiha.