With the aid of a software programme, the town hall detected listings for 1,891 lodgings that did not have proper permits on Airbnb, and another 3,929 on HomeAway, it said in a statement.
Each have been issued a fine of €60,000 ($65,000).
Since taking office in June, Barcelona mayor Ada Colau, a former anti-eviction activist, has kept her pledge to try to curb a boom in visitor numbers that she fears could drive out poor residents and spoil the charm of Spain's second largest city.
The number of visitors to the city has skyrocketed from 1.7 million in 1990 to 7.4 million last year, making Barcelona the third most-visited city in Europe, after London and Paris.
For many years the tourism boom was seen as a success story but persistent issues with noise, rising real estate prices and illegal tourist flats has led many of the city's 1.7 million residents to draw battle lines against the seemingly never-ending tide of beer-swilling visitors.
A popular 2014 documentary about Barcelona's tense relationship with visitors, "Bye Bye Barcelona", warned that the city was becoming "a theme park".
The issue was thrust into the political spotlight after newspapers in August 2014 published photos of three naked Italians frolicking through La Barceloneta, a seaside district that has many illegal tourist flats, in broad daylight, sparking protests from area residents.
In addition to fining firms like San Francisco-based Airbnb - which matches people wishing to rent out their homes or rooms to temporary guests - that market lodgings without proper permits, Colau in July halted the issuing of new hotel licenses for one year.
Colau came to power after a coalition of citizens groups which she headed won local elections in Barcelona in May.
The coalition was backed by new anti-austerity party Podemos, which gained a surprisingly high 69 seats in a parliamentary election in Spain on Sunday, making it the third political force after acting Prime Minister Mariano Rajoy's conservative Popular Party and the Socialists.