Ex-Liverpool, Real Madrid midfielder Xabi Alonso makes history at Real Sociedad B

Xabi Alonso has steered Real Sociedad's B team back into the second tier of Spanish football for the first time in almost 50 years.

Alonso, 39, has achieved the feat in just his second season in management following a storied career that saw him represent Liverpool, Real Madrid and Bayern Munich.

- La Liga on ESPN+: Stream LIVE games and replays (U.S. only)

La Real beat Algeciras 2-1 after extra-time in the playoffs on Saturday to seal their place in the Segunda Division next year.

An Imanol Ugalde own goal had given Algeciras the lead but another own goal at the other end, from Jordi Figueras, took the game into an additional 30 minutes.

Jon Karrikaburu struck the winning goal in the 105th minute for Alonso's side, with Algeciras ending the game with 10 men after a late red card for Fran Serrano.

The former Spain midfielder took over La Real's reserve side in 2019 after taking some time off following his retirement as a player in 2017.

La Real missed out on promotion in his first season in charge but won their league this season to reach the playoffs, where they beat Andorra to set up Saturday's showdown with Algeciras.

Alonso's work in San Sebastian, where he began his career as a player, has drawn interest from elsewhere, with Borussia Monchengladbach offering him the chance to coach in Germany earlier this year.

However, Alonso decided to remain put, signing a contract extension that ties him to La Real until 2022. Next season will see La Real compete in the second division of Spanish football for the first time since 1962.

As things stand, they will be the only reserve team in the league after Barcelona B lost to UCAM Murcia in the third division playoffs last weekend, although Basque rivals Athletic Bilbao B could yet join them in the Segunda Division -- they face Burgos on Sunday with promotion on the line.

Amorebieta and the winners of UCAM Murcia against Ibiza will also be promoted to the second tier next season.

As a player, Alonso won the Champions League with both Liverpool and Madrid, two European Championships and a World Cup with Spain and Bundesliga titles in each of his three seasons with Bayern, among many other trophies.