FRANKFURT - Hamburg avoided relegation by coming from behind to beat Karlsruhe 2-1 in extra time in the Bundesliga playoff on Monday.

With his team facing relegation, Marcelo Diaz scored from a free kick in the 90th minute to send the match into extra time and Nicolai Mueller secured the victory in the 115th. Hamburg won the two-leg time 3-2 on aggregate.

Hamburg also won the playoff last season on away goals against Greuther Fuerth to stay in the Bundesliga.

Substitute Reinhold Yabo scored in the 78th minute for Karlsruhe, which was a couple of minutes from returning to the Bundesliga for the first time since 2009.

Hamburg remained the only founding member of the Bundesliga never to be relegated since the league's start in 1963.