Sergio Ramos and Cristiano Ronaldo scored two goals apiece as Real Madrid advanced to the Champions League final by stunning title holder Bayern Munich 4-0 on Tuesday.

Madrid completed a 5-0 aggregate victory over the two semifinal legs and will now play either Chelsea or Atletico Madrid in the May 24 final in Lisbon. Bayern's slumped to its worst home defeat in the competition, and equaled its heaviest loss overall — 4-0 away to Barcelona in 2009.

"You dream of a perfect game, the first half was great for us," a beaming Madrid coach Carlo Ancelotti said. "The team has a great spirit for working for each other. The game turned out perfectly.

"I'd won here, so that's why I felt confident about our chances here," added the Italian, who had previously coached AC Milan to victory in Bavaria. "After 12 years to return to the Champions League final is very good for us."

Madrid had never won in Munich in 10 previous matches, losing nine of them. But this time, Ancelotti's team put its stamp on the game early and struck with awesome efficiency.

Pepe, Real Madrid

Real's Pepe celebrates after winning the Champions League semifinal second leg soccer match at the Allianz Arena in Munich. (Kerstin Joensson/The Associated Press)

"We played a perfect game in the first half, we defended very well and pressed very high," Ancelotti said. "We used the space we had for counters, with some great passing."

Ramos headed home in the 16th and 20th minutes, and Ronaldo raised his tally to a competition record 16 goals for the season to take Madrid one win away from a record 10th title. However, holding midfielder Xabi Alonso will miss Madrid's 13th final because of accumulated yellow cards.

"Goals are great, satisfying on a personal level, but what matters is what we did as a team. The overall result was deserved," Ramos said. "It's a dream come true. It's a dream game, fantastic for all Madrid fans."

After the final whistle, Madrid players put on T-shirts with the words "Now for the 10th, in reference to their obsession with "La Decima" (Spanish for the 10th).

Madrid had lost three consecutive semifinals, including a 2012 shootout when Ramos missed a penalty. Of five previous semifinal series against Bayern, Madrid had won only one. Coming into the match, Madrid had only two wins in 27 outings in Germany, with six draws.

It was a bitter defeat for Bayern coach Pep Guardiola, who had so much success against Madrid when he was in charge of Barcelona. Bayern was seeking to become the first team to defend the Champions League title.

Guardiola bemoaned the lack of possession in the first half — although UEFA statistics show Bayern had two-thirds of possession for the game.

"We didn't have ball possession and that's why we had no control," Guardiola said.

"It's a great disappointment. 0-4 sounds very bitter," Bayern captain Philipp Lahm said. "We wanted a lot, but we failed tactically in the first half."

Madrid's sweeping, fast counterattacks paced by Ronaldo, Karim Benzema, Gareth Bale and Angel Di Maria, along with its tenacious tackling when Bayern tried to come out of the hosts' own half, were a huge problem for Bayern's defence but the first two goals came from set pieces, as well as the last.

A corner by Luka Modric was met By Ramos, who headed down past Manuel Neuer, as Dante failed to challenge the Madrid defender.

The second goal came after Di Maria's swinging free kick into the box. Pepe nodded the ball on and the diving Ramos headed into the net.

"We prepared the set pieces and we used them to make things easy for us," Ancelotti said.

Real's third was a fast break that left the Bayern defence trailing far behind.

Benzema fed Bale, who easily outpaced Jerome Boateng and passed to the unmarked Ronaldo, who calmly slotted home in the 34th. Ronaldo then fired a low free kick through the wall in the 89th to complete Madrid's superb performance.

Bayern nerves frayed after the first three goals and the match threatened to get out of hand. Star winger Franck Ribery failed to make an impact and was substituted in the second half. Striker Mario Mandzukic was involved in several incidents and did not come out for the second half.

Ronaldo and Bale both missed an empty net when Neuer twice mistimed clearing attempts far outside the penalty box. Ronaldo saw another effort sail wide, although he might have done better by passing to Benzema.

The match lost intensity in the second half as Madrid protected its lead while the demoralized Bayern kept possession but rarely threatened.

A minute of silence was held before kickoff in memory of former Barcelona coach Tito Vilanova and Vujadin Boskov, a former Serbian coach of Real Madrid. Both died last week.