Over 100 officers were involved in the operation to arrest the man on Wednesday night in a neighbourhood of narrow streets in the southern city of La Linea de Concepcion, which lies across the border with Gibraltar, police said in a statement.
He is suspected of being one of the leaders of “Los Castanas”, a group that “monopolised hashish smuggling” in the Campo de Gibraltar area, the statement added.
The man had been on the run since the end of 2016 when police arrested 30 suspected members of the group in Spain and Morocco.
Police seized a tonne of hashish along with €350,000 ($410,000) and three rigid inflatable boats as part of that operation.
The organisation bought houses for poor families whose members did not have a criminal record, and gave them vehicles and money, and in return they watched over drug shipments, police said.
Earlier this year gang members stormed a hospital in La Linea de la Concepcion to free a top trafficker from police custody.
Drug traffickers are operating increasingly in the open in this part of the southern region of Andalusia, which has high unemployment. They land shipments of drugs on beaches in broad daylight and physically attack police officers.
The Spanish government has responded by sending extra police to the area.
The Linea de Concepcion is in Cadiz province, the entry point for 40 percent of the drugs smuggled into Spain, according to the interior ministry.
Police unions have said that 30 groups dedicated to drug trafficking operate in the province — just 15 kilometres (nine miles) from Morocco's northern coast — which have more than 3,000 direct collaborators.