- Fiji scored two tries in the first eight minutes playing some free-flowing rugby, but the Six Nations champions pegged them back and a Liam Williams try with 12 minutes left buried the Fijians' chances.
Winger Josh Adams scored a sensational hat-trick on Wednesday as Wales booked a Rugby World Cup quarter-final place with a 29-17 bonus-point win over Fiji, sending Australia through in the process.
In an end-to-end encounter in Oita, Fiji scored two tries in the first eight minutes playing some free-flowing rugby, but the Six Nations champions pegged them back and a Liam Williams try with 12 minutes left buried the Fijians' chances.
The result also guaranteed Australia's progress to the last eight ahead of their final Pool D game against Georgia on Friday.
But the victory may have come at a high price for Wales with playmaker Dan Biggar apparently knocked out in an aerial clash with team-mate Williams, and Adams limping off with a knee injury after his third try.
"I think the medics are going to be working pretty hard in the next 24/48 hours. But pleasing to get that bonus-point win," said Wales coach Warren Gatland.
"That was tough, they've got some unbelievable individuals and we just had to stay in it," added Gatland.
Fiji produced a flying start with two tries in a dramatic opening, in which a third try was ruled out by a forward pass and Wales went a man down when hooker Ken Owens was sent to the sin-bin for a dangerous tackle.
It was the first of four yellow cards as referee Jerome Garces lost patience with repeated fouls.
But as the game wore on the superior quality of the Welsh attack told, and forward passes cost Fiji two more tries.
Although the final scoreline was probably closer than Wales would have liked, and Fiji wing Semi Radradra was named man of the match, the Welsh did out-score Fiji four tries to three.
"I think we probably started very slow out the blocks. We knew that if Fiji got their tails up, we were going to be in for a hard day at the office," said Wales captain Alun Wyn Jones.