Some 6,000 dockers have staged work stoppages for 48-hour periods since June 5th to protest against a decree passed in May by Spain's conservative government that deregulates the hiring of dock workers.
Under the previous system, domestic or foreign companies could only hire workers to load and unload ships in Spain from specific, already-established organisations that provide personnel, and no other firms.
The new decree allows companies to contract workers wherever they want -- which employers argue will increase the competitiveness of Spanish ports. Unions argued the reform threatened the jobs.
A meeting in Madrid between labour unions and industry association Anesco "resulted in an agreement between the parties", the two sides said in a joint statement.
Anesco member firms have pledged to protect the jobs of "100 percent of the workers" who load and unload ships at Spanish ports, the statement added.
In exchange for keeping their jobs the unions accepted a reduction in the wages of the dockers of "up to 10 percent", Israel Ruiz of the UGT Estiba union told AFP.
This union member also said that in reality, the agreement does not cover all workers as some firms pulled out of the Anesco industry association.
According to his estimate, the agreement actually only covers about 70 percent of all Spanish dockers.
The strike caused losses of around €12 million ($13.6 million) per day, according to the government.
Shipping companies were forced to re-route their cargo to avoid the dockers strike in Spain, opting for Portugal or Morocco instead.
Over 60 percent of Spain's exports pass through its main ports, particularly in the food and auto sectors, which are key engines for growth.