Real Madrid will play Juventus in the final, though they had to withstand a spirited attempt at a spectacular comeback.