After losing 3-0 in the first leg of their quarter-final, Juventus scored three times at the Santiago Bernabeu to set up a tense finish.
As the match appeared to be heading for extra time, referee Michael Oliver awarded a penalty for Mehdi Benatias foul on Lucas Vazquez.
Juventus players protested the decision for several minutes and a furious Buffon was sent off for his angry reaction towards Oliver.
Cristiano Ronaldo stepped up to convert the penalty, which has sealed Madrids place in Fridays semi-final draw.
For Buffon, the match could represent his final appearance in the Champions League, although the 40-year-old has not revealed his decision over his future.
After the match, Buffon insulted Oliver in his post-match interview, claiming that the Premier League official has a garbage bin where his heart should be.
Ronaldo, meanwhile, insisted that Oliver was right to award a penalty.
And in a special moment as the players were leaving the Santiago Bernabeu, Ronaldo interrupted Buffon, who was speaking to the media, to hug the Juventus goalkeeper and say some kind words to him.
I have a lot of respect for Buffon, the words he has said about me, and what Ive said about him, Ronaldo told RTP after the match.
He is a great goalkeeper and I hope this is not his last Champions League appearance, he is one of the best goalkeepers ever.
More: Real Madrid