The detainees formed part of a group based in Thailand and linked to Lashkar-e-Taiba, a Pakistan-based terror group blamed for the 2008 Mumbai, India, attacks that killed 166 people, the ministry said in a statement.
The arrests in Spain took place late Tuesday and early Wednesday in the northeastern city of Barcelona, the ministry said.
The detainees included six Pakistanis and one Nigerian. The ministry said the group stole passports, mostly from tourists in the Barcelona area, and sent them to Thailand to be doctored and later distributed to groups linked to al Qaeda.
The ministry said the passports allowed members of the terror groups to enter European and other countries.
The group was run by one of the three people--two Pakistanis and one Thai citizen--arrested in Thailand.
The statement said that in the Spanish raids police seized passports ready to be sent to Thailand, computer and mobile telephone equipment.
The ministry said the group had also supplied forged documents to other groups, including the Tamil Tiger rebels who were crushed last year by Sri Lankan troops after a quarter-century war for an independent state for ethnic minority Tamils.