Chris Taripo's hat-trick was in vain as Tonga won a thrilling contest to keep their World Cup hopes alive and send the Cook Islands out.
Taripo went over twice in the first half to put the Cook Islands ahead, and brilliantly cut the deficit when Tonga regained the lead in the second period.
But Jorge Taufua squeezed over to ensure Tonga held on.
The Cook Islands' defeat means the USA are definitely through to the last eight, while Tonga must beat Italy.
Tonga must hope that Scotland do not beat the States in their inter-group match on Thursday, and then beat the Azzurri on Sunday.
Sika Manu gave Tonga an early lead in front of a stadium-record crowd of 10,544 at Leigh Sports Village, only for the excellent Taripo to cross twice in seven minutes.
Jason Taumololo and Konrad Hurrell bashed through in response for Tonga and, with Sydney Roosters stand-off Samsoni Langi kicking three goals, the favourites led 18-10 at the break.
But Taripo came again, producing a brilliant flying finish in the corner and kicking from the touchline to cut the deficit to two points.
Taufa gave Tonga breathing space, but still the Cook Islands fought.
Jordan Rapana dropped the ball over the line and substitute Hikule'o Malu had a try disallowed before the Cook Islands' exit was confirmed.
Tonga captain Brent Kite: "I'm not too proud to beg. Get out there USA and give us a win. We'd much appreciate it and we'd owe you one.
"We definitely need a favour. I'm not sure what they're thinking. They've played well to get themselves in the position they're in.
"I'm just hoping they're not going to take this one easy and rest too many."
Cook Islands coach David Fairleigh: "We're obviously disappointed but it was a great game of rugby league and I can't question our players efforts.
"We were there at the end to give ourselves a chance to win the game and I couldn't be more proud of them."
Tonga: Fisi'iahi, Tupou, Hurrell, Fonua, Taufua, Langi, Foster, Kite, Politini, Moimoi, Taumalolo, S. Manu, Paea. Replacements: Vave, W. Manu, Ta'ai. Substitutes: Seluini.
Cook Islands: Low, Taripo, K. Lulia, Takairangi, Rapana, Ford, John, Napa, Fepuleai, Tetavano, Peyroux, Taia, Arona, Mataora. Replacements: Tangata, Mataora, Matapuku, Malu.
Referee: Ashley Klein (Australia).