The 36-year-old free agent, who ranks third among all catchers in the majors with 50 home runs since the beginning of the 2009 season, hit .230 with 16 home runs and 47 RBIs for the Los Angeles Dodgers last season.
While no financial details were disclosed by the Pirates, local media estimate the deal to be worth $4 million in 2012 and $3.5 million in 2013.
"They were aggressive," Barajas, who said he had received offers from several other teams, told the Pirates' official website (http://pittsburgh.pirates.mlb.com/news).
"They definitely showed that they wanted me to be a part of the team. For me, to feel like I'm wanted is huge. The way they came after me, that's what you want to feel when you're a free agent."
Barajas has a career average of .238 with 125 home runs and 449 RBIs in spells with Arizona, Texas, Philadelphia, Toronto, the New York Mets and the Los Angeles Dodgers.
(Writing by Mark Lamport-Stokes in Los Angeles; Editing by Steve Ginsburg)