The 33-year-old Spain international, who arrived from Manchester United in 2008, was sent off in Tuesday’s 5-1 Champions League victory over Hungarian outfit Ferencvaros, not the way he would have liked to celebrate his new deal.
Barca confirmed a buy-out clause of 500 million euros ($591 million) in the contract, and said the extension was "subject to the player making a certain number of appearances from the 2021-22 season".
First-choice goalkeeper Marc-Andre ter Stegen also signed a new deal to June 2025, while centre back Clement Lenglet and midfielder Frenkie de Jong have been offered contracts up to June 2026.
"These agreements have been reached following weeks of negotiations and include a temporary salary adjustment due to the current circumstances brought about by the COVID-19 induced crisis," Barca said in a statement on Tuesday.
($1 = 0.8458 euros)