The gang is suspected of selling heroin to other traffickers in Spain's wealthy northeastern region of Catalonia as well as directly to users, Catalan police said in a statement.
The ring would transfer its profits to Morocco where its leaders would launder the money by buying real estate, the statement added.
Among those detained as part of the operation was the suspected leader of the group, a Moroccan national.
Police said they seized 35 kilos (77 pounds) with a street value of over €2 million as part of their investigation.
"This heroin seizure… is the biggest ever carried out by Catalan police and the biggest in Spain in 2014," the statement said.
Police said they opened their investigation in February after officers detected an "important point of sale for heroin" in the town of El Vendrell, about 70 kilometres (40 miles) south of Barcelona where the ring was based.
They monitored the site and swooped in to make their arrests on October 16 when a shipment of heroin was due to arrive from The Netherlands.
Of the 36 people arrested, 20 have been placed in preventative detention while the investigation continues.
Opium production in Afghanistan, the world's largest producer of poppy flowers which are used to make heroin, increased by 49 percent in 2013 over the previous year to reach 5,500 tonnes, according to the United Nations Office on Drugs and Crime.