City's Bernardo Silva and Mateo Kovacic both misfired in the shootout to put Madrid in the driving seat
The transfer fee could rise by another 1.5 million euros (1.19 million pounds) depending on the number of games the 24-year-old right back plays.
The five-year contract is pending a medical later this week in Spain, the Catalan club said on their website.
His signing is the latest in a busy off-season for Barcelona, who are prohibited from signing players in the next two transfer windows after they were found to have breached rules on the signing of underage players.