The detainees are accused of being part of a group based in Thailand and linked to Lashkar-e-Taiba, a Pakistan-based group blamed for the 2008 attacks on Mumbai, India that killed 166 people, the ministry said in a statement on Wednesday.
The arrests in Spain took place late on 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 groups to enter European and other countries.
The group was said to be 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, as well as computer and mobile telephone equipment.
The ministry said the group had also supplied forged documents to other groups, including the Tamil Tigers, who were defeated last year by Sri Lankan troops after a quarter-century war for an independent state for ethnic minority Tamils.