The attack, about 30 miles off the Yemeni coast, turned a desperate journey by migrants already fleeing a war zone into a scene of horror, with dead and dismembered bodies piled atop one another just steps from their loved ones in the small wooden boat.
It also drew attention to the often overlooked illegal human traffic in the waters between Yemen and the Horn of Africa, where poverty and violence in Yemen, Somalia, Eritrea and Ethiopia have pushed hundreds of thousands of people to take risky sea journeys in hopes of better lives.
The waterways they use, the Gulf of Aden and the Red Sea, also host major shipping lanes and lots of military traffic, increasing the chances that naval forces will cross paths with migrants, whose vessels can be hard to differentiate from those of smugglers.
Shabia Mantoo, a spokeswoman for the United Nations refugee agency in Yemen, said that despite years of war and economic collapse in Yemen, the country hosts more than 255,000 refugees from Somalia and took in 117,000 new refugees and migrants in 2016.
While some of the new arrivals remain in Yemen, others hope to sneak into its richer Persian Gulf neighbors, like Saudi Arabia, to look for work or to make a transit stop on their way to Europe.
Many migrants are abused or exploited by smugglers along the way, and some arrive in Yemen without knowing it is a country at war.
"Not only do they arrive in a war zone, but they are also vulnerable to unscrupulous traffickers and smugglers,” Ms. Mantoo said.
The boat attacked on Friday had launched illegally into the Red Sea from Yemen’s west coast, heading toward Sudan, from where its Somali passengers hoped to make their way to Egypt, Libya and eventually Europe, said Mr. Fadal, the Yemeni port official.
But during the night, it came under fire. Some survivors said a battleship struck it first, then a helicopter.
"I took cover in the belly of the ship,” said Ibrahim Ali Zeyad, a Somali who survived the attack. "People were falling left and right. Everyone kept screaming, ‘We are Somali! We are Somali!’”
But the shooting continued for what felt like half an hour.
"The helicopter was right over us and it had these huge lights on,” he said. "They just kept shooting.”
Al-Hassan Ghaleb Mohammed, a Yemeni trafficker who was aboard, told The Associated Press that when the helicopter attacked, the migrants held up flashlights to show that they posed no threat and the helicopter stopped firing. But dozens of passengers were already dead.
Mr. Fadal said that there were 145 Somalis on board and that 32 were killed, including at least 10 women and five children. Thirty others were wounded; 73 survived without injury; and 10 were missing.
He shared photos from the port, showing bodies and tattered clothing strewn about the boat and laid out on the pavement.
After piloting the boat close enough to the port for rescue crews to reach it, the boat’s Yemeni captain bled to death, Mr. Fadal said.
In Geneva, Mohammed Abdiker, emergencies director at the International Organization for Migration, said 42 bodies had been recovered. He called the attack "totally unacceptable” and said responsible combatants should have confirmed the identities of the boat’s passengers "before firing on it.”
Mr. Fadal said the attack on Friday was one of many in recent weeks off the coast of Yemen. An attack on a Yemeni fishing boat the night before had killed seven fishermen, he said, and another recent attack on two fishing boats killed 32 people.
"To the ships, these boats look like they are the enemy,” he said of the warships in the Red Sea. "But that is a totally unjustified fear. The rebels don’t attack enough for them to be so scared, and they can easily tell that these are fishermen or migrants.”
Also on Friday, a shelling attack on a mosque in a military base in Marib Province killed 27 people and injured 95, according to Mohammed Al Qubaty, the head of the Marib General Hospital. Military officials accused the Houthis rebels of targeting the base.