Holland ended Brazil's 2010 Football world cup campaign with a 2-1 victory over the former champions.
Brazilian star Robinho had Brazil leading 1-0 at the break but Holland rallied in the second half and scored two goals for the victory.
Two time finalists Holland will now play the winner of Uruguay vs Ghana in Cape Town next Tuesday for a place in the final.
The Dutch cause had not been helped by losing centreback Joris Mathijsen to a knee injury minutes before kick-off.
The consequent disruption to their defence was quickly apparent, and Robinho had already had one effort chalked off because of a debatable offside call against Dani Alves by the time he gave the Selecao a tenth-minute lead.
Melo delivered a ball from deep inside his own half through the heart of the Dutch defence, Robinho's run went untracked by John Heitinga and the forward was able to place his shot beyond the left glove of Maarten Stekelenburg.
Juan might have made it two midway through the half. The Roma star got across his marker to meet an Alves cross at the near post but his shot was lifted high over the bar.
Heitinga, who had already been booked for an off-the-ball trip on Luis Fabiano, was fortunate not to be sent off for a foul on Kaka as the Brazilians started to dominate.
A Robinho dribble, a Fabiano flick and suddenly Kaka was curling a shot towards the top corner, forcing Stekelenburg into an acrobatic save.
Sneijder's comfortably-saved free-kick was the only Dutch strike on goal before the break and he and his team-mates had reason to be grateful to Stekelenburg once more seconds before the interval, when his fingertips diverted Maicon's drive into the side netting.
There seemed no way back for the Dutch at that stage. Yet within eight minutes of the restart they were level, thanks in no small part to a free-kick won by Arjen Robben's dive close to the right touchline.
The set-piece was taken short, enabling Sneijder to work the ball into space and deliver a left-footed inswinger into a congested goalmouth.
Cesar came off his line to try and punch the ball clear but collided with Melo and the ball skimmed off the midfielder's head and into the net.
Kaka had a chance to re-establish his side's advantage when Mathijsen's replacement, Andre Ooijer, sliced a clearance to him on the edge of the area.
But the playmaker's shot was placed narrowly wide and, three minutes later, Dirk Kuyt flicked on Robben's corner and Sneijder found space in the six-yard box to head the Dutch into the lead.
An afternoon that had started so positively for Brazil began to take on a nightmarish tinge when Melo was shown a straight red card for a stamp on Robben with 18 minutes left.
Cesar pulled off a fine stop to prevent Sneijder from claiming his second and only a last-ditch tackle ended Kuyt's surge through the Brazilian defence as the Dutch soaked up the late pressure and made their numerical advantage count on the counter attack.