The 27-year-old has ended a four-year spell at the Bernabeu to move to Italy.
The Serie A club have plenty of money available to strengthen their squad following the sale of Edinson Cavani to Paris Saint-Germain.
Albiol becomes Rafael Benitez's fifth signing since taking over from Walter Mazzarri, following Jose Callejon, who also moved from Madrid, Dries Mertens, goalkeeper Rafael Cabral and Josip Radosevic into the club.
Albiol, who was under contract at Madrid until June 2017, was not a regular starter, but still won the Primera Division in 2012 and the Copa Del Rey the season before.
He was also a member of Spain's World Cup-winning squad of 2010 and the successful European Championship squads of 2008 and 2012 and has 40 caps for his country.
He joined Madrid from Valencia in 2009.