Netherlands secured a last-16 place in the 2014 Fifa World Cup as Memphis Depay gave them victory over Australia, who are out of the tournament.
Arjen Robben angled in a shot to put the Dutch ahead, but Tim Cahill soon equalised with a stunning volley.
Mile Jedinak slotted in a penalty for Australia before Robin van Persie lashed home to level it at 2-2.
Mathew Leckie then missed a chance for the Socceroos, and Depay sent in a 25-yard shot for the winner.
Netherlands demolished holders Spain in their opening game and, though they came nowhere near those heights, they had enough to overcome a bold Australia at the imposing Estadio Beira-Rio in Port Alegre.
Progress to the last 16 was secured after holders Spain were beaten by Chile, who join the Dutch on six points in the group.
Having lost to Chile in their first match, Australia’s hopes of reaching the next round are over, but their youthful side certainly gave Netherlands a scare.
Socceroos coach Ange Postecoglou said before the game his side intended to attack – and they were true to his words in the opening exchanges.
But a flash of quality from Robben saw the Netherlands take the lead against the run of play. The Bayern Munich forward feinted his way past Alex Wilkinson on the halfway line, raced towards the Australia goal and drove in an angled shot for his third goal of the World Cup.
The Socceroos responded immediately with one of the goals of the tournament so far, Cahill meeting an angled ball from the right with a powerful left-foot volley which crashed in off the underside of the crossbar.
Had midfielder Mark Bresciano and defender Matthew Spiranovic shown the same poise, Australia could have taken the lead earlier than they did.
Bresciano ran onto a low Leckie cross only to shoot over from just inside the area, while Spiranovic got away from his marker at a free-kick but side-footed an eight-yard shot straight at keeper Jasper Cillessen.
Dutch coach Louis van Gaal had complained about his view from the dugout before the match – and much of what he saw is not likely to have pleased him, especially defensively.
Cahill and Van Persie were both ruled out of their teams’ final group games after being shown their second yellow cards of the tournament, either side of Leckie having a goal disallowed after he was adjudged to have fouled Daley Blind.
But Australia continued to press, and went in front when an Oliver Bozanic cross struck the hand of Daryl Janmaat and Jedinak slotted home from the spot.
The lead did not last long, though, as Van Persie netted his 11th goal in 10 internationals, controlling the ball before turning and firing into the roof of the net.
Australia again opened up the Dutch and Tommy Oar crossed for Leckie, who chested rather than headed the ball straight at Cillessen.
But it was Depay who decided the outcome of the game, the 20-year-old PSV Eindhoven winger curling a shot beyond the reach of Mat Ryan to give Netherlands their first victory in four games against Australia.
Australian coach Ange Postecoglou:
“I just wanted the players to get the reward for the way they went about things today.
“I have put a lot of pressure on the players and the staff that we are going to be a certain type of team and take it to world-class opposition, but it is one thing saying it and another thing doing it.
“They did that today but didn’t get their reward. It’s heartbreaking and massively disappointing.”
Netherlands manager Louis van Gaal:
“If in the first half you lose the ball so simply or so often, then the formation doesn’t matter. I needed to change something at half-time to boost their confidence and change their mindset.
“Fortunately it turned out OK, but it could have turned out differently. In the second half we had more chances and the way the players came from behind was incredible. To recover and correct that situation showed a lot of mental strength.”