Due to their financial predicaments, Xavi Hernandez's side were only able to offer Alonso a one-year deal when he joined from Chelsea on a free transfer at the start of the season.
But they are now in a position to give him a longer contract until the summer of 2024.
Alonso has made 19 appearances for Barcelona so far, scoring two goals and won his first trophy with the club earlier this month when the Blaugrana beat Real Madrid 3-1 in the Spanish Super Cup held in Saudi Arabia.
A club statement from the La Liga leaders read: “FC Barcelona and Marcos Alonso have reached an agreement for the player to extend his contract until 30 June 2024. The buyout clause has been set at 50 million euros.
“The event at which pen was put to paper took place this Friday in the offices at Spotify Camp Nou, with president Joan Laporta in attendance along with first vice-president Rafa Yuste, the vice-president for the economic area Eduard Romeu, director of football Mateu Alemany and director of sport Jordi Cruyff.”
Xavi expressed delight with the 32-year-old's extension, adding: “I am really happy with Marcos. Firstly because he’s a great professional. He has adapted really well to the team.”
“He’s an experienced player, he can play in different positions. He’s been a top signing, he’s improving and will be really important.”