The city issued a fine of €315,000 ($335,000) for each of the empty apartments, which the banks have had on their books for over two years, and which they have refused to hand over to the authorities to be used as social housing, a statement said.
In total, the fines came to €1.26 million.
The country's two largest banks, Santander and BBVA, were slapped with one fine each. Meanwhile Spain's “bad bank” Sareb, set up in 2013 to take on billions of euros in land, buildings and loans inherited from bailed-out banks, was given two fines.
“The goal of the municipality is not to collect money, but to ensure that homes have a social use,” said Barcelona's city councillor for housing, Josep Maria Montaner.
The law allowing Barcelona to crack down on banks with empty homes was passed by the previous city council in 2014.
But it has only been applied since Ada Colau, a former anti-eviction activist, became mayor of Spain's second largest city in 2015.
Colau has long signalled that the right to housing is one of her mayoral priorities and has vowed to build 8,000 new social housing flats.
Spain was one of the worst-affected countries in Europe in the financial crisis of 2007-8.
The nation's property bubble burst and unemployment soared, leaving many unable to meet their rising mortgage payments. Across the nation, thousands were evicted by their lender banks.