Alonso had been linked with taking over at Bundesliga side Borussia Monchengladbach by various German tabloids earlier this week.
Monchengladbach will lose manager Marco Rose to Borussia Dortmund at the end of this season.
"Real Sociedad and Xabi Alonso have reached an agreement to renew the Real Sociedad B coach's contract until June 30, 2022," a Real Sociedad statement read on Friday.
"Xabi Alonso has been excited about 'continuing to grow in the project' and comforted by 'helping in the last push of Zubieta's formation'.
"With the participation in the Second B Pro achieved, Alonso has 'more goals and ambitions this season that will make us challenge ourselves."
Alonso represented Real Sociedad, Liverpool, Real Madrid and Bayern Munich in a storied career that yielded four league titles and two UEFA Champions League trophies. The 39-year-old also won two European Championships and one FIFA World Cup with Spain.
"I'm very happy with how things are going," said Alonso. "I have had great communication with the club and I want to keep growing and helping with this project.
"These have been two very enriching years for me for me and the club. We still have higher aspirations and a lot in front of us to fight for.
"We have huge ambitions."