FRANKFURT - A spectator ran onto the pitch and hit Franck Ribery with a scarf in stoppage time of Bayern Munich's 3-1 victory at Hamburger SV in the second round of the German Cup on Wednesday.

The man ran the width of the field before hitting the French winger, who had secured victory for the cup holders. The intruder also made insulting gestures before being caught by guards and escorted from the pitch.

"Fortunately, nothing much happened," a relaxed and smiling Ribery told German television after the match. "It was a difficult situation, I didn't see him coming."

The Hamburg club later apologized to Bayern and Ribery. "We apologize for the scene shortly before the end. That's not HSV," the club said.

Ribery had been booed by Hamburg fans every time he touched the ball.

Bayern took advantage of a dreadful Hamburg mistake and a poor refereeing decision to take a two-goal lead before Ribery scored with a deflected shot in the second half.

"Our goal is to stay in this competition until the end," said Bayern captain Philipp Lahm, whose team next faces Borussia Dortmund in the Bundesliga.

Other top Bundesliga teams also won, but 10-man Bayer Leverkusen only prevailed in a shootout over fourth-division Magdeburg, with goalkeeper Bernd Leno saving three penalties.

Borussia Moenchengladbach won 2-1 at Eintracht Frankfurt, Hoffenheim beat second-division FSV Frankfurt 5-1 and Wolfsburg defeated second-division Heidenheim 4-1.

Freiburg got a hat trick from Admir Mehmedi to beat second-tier 1860 Munich 5-2.

Robert Lewandowski and David Alaba scored the first two goals for Bayern, while Pierre-Michel Lasogga netted a late consolation goal for Hamburg.

Thomas Mueller anticipated a horrible back pass from Heiko Westermann, picked up the ball and fed Lewandowski, whose first effort was cleared off the line by Johan Djourou. But the ball fell for Lewandowski, who drilled it inside the post in the seventh minute.

Mueller netted himself later but had the strike disallowed for offside before Alaba doubled the lead shortly before halftime.

Bayern was given a throw-in although the ball had bounced off Lahm. With Hamburg's players still out of position, Xabi Alonso got the ball from the throw-in and fed Alaba, who fired home from nearly 30 metres (yards).

Hamburg goalkeeper Jaroslav Drobny got his hands on the shot but couldn't keep it out, and Bayern had a comfortable lead despite creating few chances.

Ribery's shot from the edge of the box in the 55th minute deflected off Djourou, wrongfooting Drobny, and put the match beyond doubt. Drobny made a pair of late saves to keep the score respectable.

In Magdeburg, Leverkusen levelled for 2-2 five minutes from the end of extra time, after playing with 10 men from the 78th-minute following a red card for Son Heung-min.

Emir Spahic and Stefan Kiessling missed penalties as Leverkusen fell a goal behind in the shootout, but Leno then produced three saves to give Leverkusen the victory.

In Frankfurt, Moenchengladbach's goals came from Thorgan Hazard and Ibrahima Traora as their team stretched its unbeaten run to 16 matches in all competitions, one short of the club record.

The draw for the third round pitted Bayern against second-tier Eintracht Braunschweig. Leverkusen will face another second-division team, Kaiserslautern, while Moenchengladbach meets fourth-division Kickers Offenbach. The only paring between top-division clubs is Freiburg vs. Cologne.