German club Bayern Munich have announced that former Barcelona boss Pep Guardiola will take over as their manager at the end of the season.

The 41-year-old - who had been linked with Chelsea and Manchester City - has signed a three-year contract to 2016.

Guardiola will replace current boss Jupp Heynckes, who will retire.

Pep Guardiola factfile Born: 18 January 1971 in Santpedor, Spain.

Playing career: Barcelona B (1990-92), Barcelona (1990-2001), Brescia (2001-02), Roma (2002-03), Brescia (2003), Al-Ahli (2003-05), Dorados (2005-06)

International caps: 47 (Spain 1992-2001)

Managerial career: Barcelona B (2007-08), Barcelona (2008-2012)

Honours (as manager): 3 La Liga titles, 3 Supercopa de Espana titles, 2 Copa Del Rey titles, 2 Champions League titles, 2 Uefa Super Cups, 2 Fifa World Club Cups.

Honours (as player): 6 La Liga titles, 2 Copa del Rey titles, 1 Supercopa de Espana, 1 European Cup, 2 Uefa Super Cups, 1 Uefa Cup Winners' Cup, 1 Olympic gold medal.

The Spaniard has been on a season-long sabbatical since after winning 14 trophies - including two Champions League titles.

"We are very pleased that we have managed to convince the football expert Pep Guardiola, who was coveted and contacted by many top clubs, to come to Bayern Munich," Bayern chief executive Karl-Heinz Rummenigge said.

"He is one of the most successful coaches in the world and we are sure that he can make not just Bayern, but all of German football shine."

Bayern are currently nine points clear at the top of the Bundesliga, and face Arsenal next month in the last 16 of the Champions League.

Heynckes, 67, informed the Bundesliga club before Christmas that he did not want to extend his contract beyond this summer.

His contract expires on 30 June, with Guardiola taking charge the following day.

Bayern's general manager Uli Hoeness said: "Only a coach of Guardiola's calibre came into consideration as a successor to Jupp Heynckes."

Some of Europe's biggest clubs had been linked with the Spaniard since he left Barcelona, including English trio Manchester United, Manchester City and Chelsea, Italian giants AC Milan and big-spending Paris St Germain.

Archive: Pep Guardiola's emotional Barcelona exit

The appointment of former Barcelona duo Txiki Begiristain and Ferra Sorriano at the Etihad Stadium had fuelled speculation City could be a possible destination for Guardiola.

Speaking in November, Milan president Silvio Berlusconi said: "Who would not want someone like Guardiola? There are some English clubs after Guardiola, especially [Manchester] City who have directors that we know very well. We will try to sign him, but it's going to be difficult."

Rummenigge, meanwhile, backed Heynckes, now in his third spell at Bayern after returning to the club in June 2011, to continue to excel in his final months as coach, having guided Bayern to a nine-point lead in the standings as the Bundesliga resumes following the winter break this weekend.

"As a club and as Jupp Heynckes' friends we have to show understanding for this decision. We have to accept it and we have to respect it," Rummenigge added.

"During personal talks with Jupp Heynckes we assured each other that we will do anything we can - and even more so now - to have a successful second half of the season and bring the title to Munich."

quote Bayern Munich is one of the best clubs in the world, if not the best Former Bayern Munich midfielder Dietmar Hamann

that he wanted to take on the "challenge" of managing an English club at some point in the future.

He said: "As a player I couldn't realise my dream to play [in England]."

"But I hope in the future, I have a challenge to be a coach or a manager there."

Guardiola retired from playing in November 2006 and was named Barcelona B coach in 2007, but spent only a year in charge before being promoted to replace Frank Rijkaard as boss of the senior side.

Under Guardiola, Barcelona established themselves as the dominant force in club football, with two Champions League crowns and three La Liga titles among the trophies claimed by a side containing names such as Lionel Messi, Xavi and Andres Iniesta.

"Bayern Munich is one of the best clubs in the world, if not the best," ex-Bayern midfielder Dietmar Hamann told BBC Radio 5 live.

"If he'd chosen Chelsea he'd have been given more time but Bayern have been to two Champions League finals in the last few years and he must feel he has a serious chance to win the Champions League with them - they're right up with the top clubs in Europe."

Former Bayern, United and City midfielder Owen Hargreaves told BBC Radio 5 live: "I think it's a smart move. People look at the glamour of the Premier League and its global appeal but he probably saw the structure in place at the club, its success and quality of players.

"The facilities and stadiums are perhaps better than anywhere in the world, he probably saw this and, in my opinion rightfully so, thought that was the best destination for him.

"Barcelona, Real Madrid and Manchester United are some of the biggest clubs in the world but Bayern are easily in that top five, regardless of what order you go 1-5."