Quaresma chipped over a lovely cross from the right and Simao darted in front of central defender Luisao to hit the ball first time low into the corner past keeper Helton to put Portugal in front in the 82nd minute.
Carvalho hooked home a cross in the final minute to secure the victory that gave Portugal coach Luiz Felipe Scolari his second win over his home country since a 2-1 victory in Porto in 2003.
• Scolari draws confidence for Euro battle
It was Dunga's first defeat in six internationals as Brazil coach since taking over from Carlos Alberto Parreira after last year's World Cup. It leaves the Brazilians, who have won 11 of their 17 meetings with Portugal, still looking for their first win over their old rivals since 1989.
Brazil had the better of the first half, forcing Portugal into isolated counter-attacks and the South Americans came close to going ahead two minutes before the interval when centre back and captain Lucio hit the bar from close in following a free kick.
Lively midfielder Elano served notice of what to expect when he brought a save from Ricardo in the fourth minute, the keeper tipping his free kick from the right wing over the bar.
But Elano faded in the second half and was unable to repeat his two-goal performance against Argentina when Brazil beat their arch-rivals 3-0 at the same ground in September.
Kaka, dominant in the first half, also faded and Brazil lost their grip on midfield after the break with Portugal gradually making more and more inroads into the defence but not before several first half scares.
Ricardo saved with his feet from Rafael Sobis after a quarter of an a hour and the striker was just wide with a header near the half hour following Elano's neat one-two with right back Maicon and cross to the far post.
There was good quality play from end to end and no shortage of passion despite the 'friendly' tag to the delight of a crowd of nearly 60,000.
Scolari draws confidence for Euro battleThey collected no points but Portugal coach Luiz Felipe Scolari claimed his team had taken a huge step towards European Championship qualification with a 2-0 friendly win over Brazil at the Emirates Stadium.
With a crucial game against Belgium next up, Scolari's men will take a huge
confidence boost from their victory over the five-times world champions, which
came via late goals from Simao Sabrosa and Ricardo Carvalho.
'My team has gained confidence and improved their credibility,' Scolari
said.
'This is part of the journey to 2008. The decisive games will be in March,
but this was a good opportunity to put some different players in and see how
they did.
'This is a victory over a team in the top position in the world and it gives
us more confidence for our game against Belgium. With this win, we become
stronger for a game which we need to win.'
Brazil dominated a frantic first half but, after the break, the game settled
down and Portugal began to get more chances on the break, finally ended the
deadlock when Simao hit a beautiful volley in the 83rd minute.
Carvalho settled it with a close-range strike in the final minute, thrilling
the Portuguese contingent in the crowd but sending the bulk of the fans -
Brazilian - to the exits.
'I thought it was a great game,' Scolari said.
'We understand that Brazil had better opportunities but we made better use of
ours.
'It was a game of two good teams with good technical ability that have more
or less the same style of playing, and those that have come - the English fans -
will have enjoyed it.'
The Brazilian-born Scolari led the South Americans to their last World Cup win
in 2002, but insisted there was no special significance to tonight's victory.
'If it's against England, France, Holland, it doesn't have any special
flavour, I have to see the collective good,' he said.
'People in Brazil still like me,' he added with a smile. 'This is a
friendly game. If we were playing in a World Cup, maybe they would get upset
with me.'
Scolari had handed the captain's armband to Cristiano Ronaldo, who turned 22
on Monday.
He explained this was at the request of Carlos Silva, the vice-president of
the Portuguese FA who died on Saturday. A minute's silence was held before the
game.
It was a first defeat as a coach for Brazil's Dunga, who took charge of the
team after the World Cup.
'We anticipated these would be dangerous opponents,' he said.
'We should have played the ball more down the wings because, when you go
through the middle, you leave yourself open to counter-attacks.
'We have to learn from it. We are starting to prepare for the World Cup. This
showed us we have much left to learn. That is football.
'I thought we would win, but you are not always going to.
'You have to take responsibility as coach.'
Brazil were without Ronaldinho, who pulled out with a calf injury, but Dunga
denied suggestions there was a problem with the Barcelona star.
'I work with my players directly,' he said.
'Ronaldinho has not had any problems with us. All of my players I speak to
directly. I am never going to deal with them via the media.'