After starting out at Boavista, he signed with Porto in 2004, going on to appear in 198 official games and win ten major trophies, including four Primeira Liga titles in a row. From 2010 to 2012 he competed in the Premier League, with Liverpool and Chelsea, winning the 2012 Champions League with the latter; he also spent several seasons in Turkey, with Fenerbahçe.