Alonso began his career at Real Sociedad, the main team of his home province Gipuzkoa. After a brief loan period at Eibar, he was appointed as team captain of Real Sociedad by then-manager John Toshack. He succeeded in the role, taking the club to second place in the 2002–03 season. He moved to Liverpool in August 2004 for £10.5 million and won the UEFA Champions League in his first season, under manager Rafael Benítez, scoring the equalising goal in the Final against Milan. The following season, he won the FA Cup and the FA Community Shield.