(CNN) -- The crew of an Italian ship seized by pirates on Monday was freed Tuesday thanks to an operation by U.S. and British troops working with the Italian military, the Italian Foreign Ministry said Tuesday.
Eleven pirates who hijacked the Montecristo surrendered to the troops operating under NATO's Operation Ocean Shield, the ministry said in a statement.
All crew members are safe, the ministry said.
They barricaded themselves in the engine room after throwing a message overboard in a bottle and putting up a cardboard sign to let rescuers know where they were.
They were able to retain control of the ship's steering, even though the pirates destroyed the ship's communications equipment, a NATO officer said.
The USS De Wert was the first ship to arrive on the scene, and monitored the hijacked vessel until the British ship HMS Fort Victoria arrived with a boarding team, Lt. Gwenn Laine of NATO told CNN.
The pirates threw their weapons into the sea as the boarding team closed in, and stood on deck to surrender once they boarded, Laine said.
He praised the crew for following "best maritime practices," saying that by barricading themselves in a safe place they probably avoided violence.
The pirates are in NATO custody, said Laine, who works with the alliance's Operation Ocean Shield.
The captain sent a message Monday indicating that the vessel had been attacked by a ship with five armed people on board, the D'Alesio Group said in a statement.
The captain immediately activated security procedures, the statement said.
The ship was about 1,000 kilometers (620 miles) east of the Somali coast at the time.
The crew includes 23 people from Italy, Ukraine, and India, the D'Alesio Group said.
Their rescue came shortly after Italy said it would start putting military guards on ships traversing the pirate-infested waters off the coast of Somalia
Defense Minister Ignazio La Russa is signing an agreement Tuesday with the confederation of Italian shipowners to put military guards on board vessels in the area of the Indian Ocean at risk from Somali pirates, his ministry told CNN.
Both NATO and the European Union have naval missions dedicated to protecting ships in the region, but hijackings remain common.
As of late September there were some 400 hostages held by Somali pirates, according to the International Maritime Bureau.
There have been 24 successful hijackings this year to date and 194 incidents. The number of incidents is up from last year, but the number of successful hijackings down, according to the IMB.
CNN's Richard Allen Greene, Chris Lawrence, Claudia Rebaza, Gisella Deputato, Laura Perez Maestro and David McKenzie contributed to this report.