EXETER, England (AP) — Italy ended its Rugby World Cup campaign with an entertaining 32-22 win against a valiant Romania on Sunday to secure third place in Pool D and automatically qualify for the 2019 tournament.

Despite the win and qualifying, Italy coach Jacques Brunel still had last weekend's 16-9 defeat to Ireland in mind.

"I won't be celebrating. We finished third," Brunel said. "We were close to qualifying for the quarterfinals but didn't manage it. For me, that's a big disappointment."

Italy's other tournament win was against Canada, 23-18.

"If we consider that our mission was to come out of the pool, we nearly achieved our goal," Brunel said. "We can't achieve miracles."

Romania made the biggest comeback in World Cup history when it rallied from 15-0 down to beat Canada 17-15 in midweek, but ran out of time for more heroics.

The Oaks, however, did brilliantly to stop a landslide defeat, having trailed 22-3 at halftime and then 29-3 when No. 8 Alessandro Zanni burrowed through a gap six minutes into the second half.

Scrumhalf Edoardo Gori, right winger Leonardo Sarto, and flyhalf Tommaso Allan touched down for Italy in the first half.

If Romania's players could market their refusal to accept defeat, they would be overnight millionaires, and they roared back with a vengeance with three tries in the last 15 minutes.

Romania's rolling maul finally kicked into gear, resulting in a try from replacement left winger Adrian Apostol, who took a feed from No. 8 Daniel Carpo and dotted over.

That made it 29-10 with 13 minutes remaining and, just to be safe, Allan took a penalty kick in front of the posts, drawing some jeers from the try-hungry crowd at Sandy Park. But there was more at stake than entertainment value, and the Italians were right to be cautious in light of Romania's never-say-die attitude.

Lock Valentin Poparlan barged his way over for a try he was not even aware he had scored, until it was awarded following several video referrals that stalled a flowing game.

Then, with one minute remaining, Apostol capped off a sweeping move with another try down the left, prompting a jubilant reaction from coach Lynn Howells.

But it was too late.

Italy finished behind Six Nations rivals Ireland and France — who played their pool decider late Sunday — and Romania ended in fourth spot.

"I am just disappointed with the way we finished the World Cup," Howells said, "because we had a chance to beat a Tier One nation and didn't take it."

In a one-sided first half, Italy had two more tries ruled out for knock-ons.

If Romania had only started the tournament the way it finished, perhaps Howell's teams would be booking tickets in 2019 to Tokyo.

Romania was missing inspirational captain and No. 8 Mihai Macovei, scorer of both tries against Canada, but suspended for a dangerous tackle during that match.

Italy was also missing its talismanic No. 8, with captain Sergio Parisse, sidelined with a niggling calf injury.

On the first scrum, Romania's pack shoved Italy back several meters, won a penalty, and inside center Florin Vlaicu — who landed the match-winning penalty goal against Canada — gave Romania a fifth-minute lead.

Italy hit straight back, as Gori burst through in midfield, chased his own kick and beat Romania fullback Catalin Fercu for pace. But a television referral showed that he knocked on.

Italy took its next chance, as outside center Michele Campagnaro fed Sarto for a try in the left corner. Allan missed the conversion from wide left, but landed a penalty soon after as Romania lock Johannes van Heerden was sin-binned for tripping.

"While Van Heerden was off the field we conceded 10 points and that was the difference," Howells said.

Although hooker Andrea Manici crossed the line and knocked on, Gori made up for his earlier miss when he darted over from close range for a converted try.

Then, Italy's defense withstood 11 Romanian attacking phases, gradually sapping their energy — but never their belief.