Panama has ordered the release of 32 crew members of a North Korean ship seized six months ago in the Panama Canal, carrying Cuban weapons.
The captain and two other crew members will remain in detention as they are facing weapons trafficking charges.
Cuba said that the Soviet-era jet planes and weapons were being taken to North Korea to be repaired.
But the United Nations says this was a breach of international sanctions against North Korea.
The Panamanian authorities said that taking the cargo through the canal endangered the country's internal security.
Earlier this month, the ship's owners agreed to pay $670,000 (£400,000) to have the vessel released.
Documents have been found showing that "the ship's captain, the first officer and the political officer had been given instructions about what to do if the illegal shipment was detected," prosecutor Nahaniel Murgas said.
The 32 crew members also gave statements denying knowledge of the illegal cargo.
As a result they are being released without charge, but the captain and the other crew members face 12-year sentences for arms smuggling.
The container ship - the Chong Chon Gang - was stopped near Manzanillo, on the Atlantic side of the canal, on 15 July under suspicion that it was carrying drugs.
It had disappeared from satellite tracking for a few days as it approached the Cuban capital, Havana, having departed from Russia's eastern coast three months earlier.
Officials found 25 containers of military hardware, including two Soviet-era MiG-21 fighter aircraft, air defence systems, missiles and command and control vehicles.
Cuban authorities said that the ship was carrying 240 tonnes of "obsolete" defensive weapons.
A United Nations panel of experts was sent to Panama three weeks later.
The North Korean government had called on Panama to release the vessel.
"This cargo is nothing but ageing weapons which are to be sent back to Cuba after overhauling them according to a legitimate contract," the North's foreign ministry was quoted as saying by the state-run Central News Agency.
The UN team later published a preliminary report saying that sanctions against North Korea over its nuclear programme had been violated.
Under UN sanctions, North Korea is banned from weapons exports and the import of all but small arms.