"Banco Santander has reached a cooperation agreement with Bank of Shanghai to buy an eight percent equity stake" in the Chinese bank from British lender HSBC, Santander said in a statement.
The investment, which is subject to approval by Chinese regulators, will cost Santander €470 million ($647 million), it said.
The deal makes Santander the second-largest shareholder in Bank of Shanghai and a strategic international partner, the statement added.
The two institutions would develop joint wholesale banking activities in China, it said.
Santander is the biggest bank in Europe by market capitalization. In May it got regulator approval to buy a stake in another Chinese lender, Bank of Beijing.
The statement called Bank of Shanghai "the second-biggest urban commercial and retail bank" in China, with eight million personal banking customers and almost 200,000 corporate customers.