The activists, from countries including Indonesia, the scene of mass deforestation for palm oil plantations, were held by the captain of the ship after they boarded at sea, the NGO said in a statement.
Prior to that, “they unfurled banners reading 'Save our Rainforest' and 'Drop Dirty Palm Oil',” it added.
The ship was travelling from Indonesia, the world's top palm oil producer, to Rotterdam in the Netherlands, the NGO said.
The captain has turned the ship around and is heading to Spain, it added, where he intended to hand the activists over to authorities.
When contacted by AFP, the Guardia Civil police force said it had no knowledge of the matter.
According to Greenpeace, the ship is carrying “dirty palm oil” products, or those linked to mass deforestation.
Palm oil is a key ingredient in many everyday goods.
Growing demand for the commodity has led to an industry boom in Indonesia.
Green groups have long accused palm oil companies of rampant environmental destruction.
Many firms have made “no deforestation” pledges after coming under pressure, but activists say such commitments are hard to monitor and frequently broken.
As well as the destruction of rainforest, clearing peatland to make way for palm oil plantations causes enormous environmental damage.
Huge amounts of carbon are released when peat is drained or burnt, exacerbating climate change, according to environmentalists.
Peat fires are also difficult to put out and a key factor in outbreaks of toxic smog which choke Southeast Asia almost every year.