Barca tried to sign Martinez last summer, but they could not agree a fee with Athletic, who held on to the Spain international despite at the risk of losing him as a free agent this year.
However, they maintained their interest in bringing him in, with negotiations accelerating at the start of the year after Gerard Pique retired from football.
ESPN reported in March that Barca had reached a verbal agreement with Martinez, who left Athletic when his contract expired last month.
Barca's defence was one of their strengths as they sealed a first LaLiga title since 2019 this season, with Xavi Hernandez's side keeping 26 clean sheets in 38 league games.
However, Xavi was keen to add a left-footed centre-back to his options, with Martinez also adding experience to what is a relatively young backline.
Martinez began his career with Real Sociedad, making over 200 appearances for the club before joining their Basque rivals Athletic in a deal worth €32 million ($34.8m) in 2018.
He made 177 appearances for Athletic and helped the club beat Barca to win the Spanish Super Cup in 2021, but will now embark on the next chapter of his career at the Spanish champions.