MADRID — Borussia Dortmund needed every bit of its first-leg advantage to stave off a comeback attempt by Real Madrid and reach the Champions League final for the first time since 1997.

Karim Benzema scored in the 83rd minute and Sergio Ramos in the 88th, putting Real Madrid in position to advance with one more goal. But Dortmund held on for a 4-3 aggregate win following a 2-0 loss Tuesday night.

“They put a lot of pressure on us,” Dortmund midfielder Kevin Grosskreutz said. “However, we are a great club and deserved to go through.”

Bundesliga champion Bayern Munich has a four-goal advantage on Barcelona ahead of Wednesday’s game. The Champions League final is May 25 at London’s Wembley Stadium, setting up the possibility of the first all-German final in soccer’s top club competition.

“Wembley will be one of the greatest moments in our lives, but whichever team we meet, we will not be the favorite,” Dortmund coach Juergen Klopp said. “In Wembley everyone will see we are not going to be satisfied with just being a finalist.”

Madrid, which has not reached the final since winning its record ninth title in 2002, was eliminated in the semifinals for the third straight year under coach Jose Mourinho. Trailing Barcelona by 11 points in the Spanish League with five games left, Real’s only realistic hope for a title this season comes when it hosts Atletico Madrid in the Copa del Rey final on May 17.

Mourinho is expected to leave after his third season, perhaps to return to Chelsea in England’s Premier League. Asked whether he will remain with Madrid next season, Mourinho replied: “Maybe not.” He then said, “I love to be where people love me to be.”

“I know in England I am loved. ... I know I’m loved by some clubs, especially one,” he said. “In Spain the situation is a bit different because some people hate me.”

Dortmund’s last visit to the final since 1997 was a 3-1 victory over Juventus at Munich’s Olympic Stadium for its only European title.

Robert Lewandowski, who scored all four goals for Dortmund last week, missed two good chances in the second half, shooting over the crossbar in the 49th and hitting the crossbar a minute later. Diego Lopez kept Madrid in the series when he dived to save Ilkay Gundogan’s close-range shot in the 62nd.

English referee Howard Webb called for five minutes of stoppage time, creating a nervy finish after Ramos’ goal.

“It’s a shame. Sometimes you lose. That is football,” Ramos said. “In Dortmund we should have played the way we did tonight. We feel for the fans. It’s a shame to have been so close, but the missed chances in the first half were costly.”

No team has overcome a three-goal deficit from the first leg in a Champions League knockout stage matchup since Deportivo La Coruna beat AC Milan 4-0 in the 2003-04 quarterfinals for a 5-4 aggregate win.