Migrants wait onboard of the Red Star 1 on Sunday in the port of Benghazi, Libya. Around 900 people, most of them from Niger, arrived from the battered city of Misrata on a ship organized by the International Organization for Migration. (Bernat Armangue/AP)

Some walked to the port and slept for weeks in squalid camps less than a mile from the docks. Some went from house to house searching for safety before concluding that there was no secure place in the Libyan city of Misurata. And some, injured by indiscriminate artillery fire, cluster bombs and bullets, were sped to this ship in ambulances.

All shared a common goal: to get away from Misurata. Even as rebels claimed victory and Moammar Gaddafi’s forces were said to be withdrawing, the shelling, rocket fire and mortar attacks continued, and the port was the only way out.

As migrant workers, the injured and the displaced lined up Saturday to board the Red Star 1, everything they had left with them was packed in small bags. The ship’s trip marked the fourth rescue mission to Misurata arranged by the International Organization for Migration.

In the city, the violence continued. Thirty-one people were killed and more than 80 injured on Saturday, according to doctors at the Hikma hospital in Misurata, where the streets have been renamed for those who have died in the nearly two-month-long siege.

On Red Star 1, Jeremy Haslam, who works for IOM, an intergovernmental organization, looked around, his eyes tired and face drawn. He made difficult choices about who could board the blue-and-white ship for the 18-hour trip to Benghazi, the de facto capital of the Libyan opposition, and who would be turned away.

The boat could take no more than 1,000 passengers. At times, more than 10,000 foreign workers had been sleeping at the port. Now about 2,400 are in the camp, according to the Libyan Red Crescent. But more come every day.

“It’s heartbreaking every time I say no,” Haslam said.

As the ship pulled away, a Libyan family clutching brown suitcases and pink blankets watched their hope for an escape leave the docks. They would try again tomorrow. Maybe they would pile on to a small fishing boat, maybe a ship funded by the government of Qatar.

Omar Hussein walked to the port three weeks ago in an ill-fitting green suit. The Niger national, who worked in a Misurata shop that sold curtains and kitchenware, had been stranded amid the fighting. As bombs exploded around him and gunfire filled the air, he walked for three hours, toward what he hoped would be his escape route.

On Saturday night, sitting on a wooden chair in the cruise ship’s cafeteria, he dozed off. The mostly Albanian and Romanian crew had turned in for the night, after serving a late lunch of pasta and green bean salad. Hundreds of other men from Niger slept on the green carpeting of the top deck and the wooden dance floor of a disco. Their bodies blanketed every space of the floor.

“I’ve been waiting for so long,” Hussein said, holding his gold-rimmed glasses in his hand. “I was so scared. There were so many bombs.”

This was the first part of his journey home.

All his worldly possessions were in the cargo hold below, along with the injured, sprawled out on mattresses. Many had shrapnel wounds to their legs, arms and other parts of their bodies. Intravenous drips were attached to some of the wounded, as family members sat with them.

“My family doesn’t know if I’m dead or alive,” Hussein said.

Signs posted in the bathroom urge passengers to conserve water during the trip and wished those leaving Misurata a “pleasant and safe trip home.” But the 136 Libyans who were making the journey were fleeing the only place they have ever known.

Umm Mohammed left behind everything she had when she fled her western Misurata neighborhood.

Gaddafi forces broke down the door, she said, taking her son and four other men from the house. She fled with her six other children and grandchildren.

She said her neighborhood is controlled by Gaddafi’s forces and has been severely damaged. There is no water, food or toiletries, she said. Rebel leaders estimate that more than half of the city’s 500,000 people have been displaced because of the violence.

“I can’t believe what Gaddafi did to his people,” she said early Sunday as most people slept.

She lived in mosques, schools and homes of relatives for 20 days and then made the trip to the port Saturday. She was too afraid to give her name, worried her son would be killed.

“I have no house now. No place to live,” she said. “If my son is alive, I will come back to Misurata. If he’s not, I can never come back.”

She looked away, her face framed by a delicate flowered scarf.

“They wouldn’t let me give him his shoes,” she said, tears streaming down her face. “That’s what bothered me most. He left the house barefoot. And he’s walking somewhere without his shoes.”

By 10:30 on Sunday morning, Umm Mohammed was in Benghazi and eager to meet her mother, who lives there.

Hussein went on to a transit camp, hoping to travel to Egypt and, if the IOM could pay for his plane ticket, then go home to Niger.

Those who had made the journey felt safe. But they were all too aware that the suffering continued in the city they had left behind.

“There are places in Misurata that no one can get to and it’s all killing,” Umm Mohammed said Sunday. “No one understands what’s happening there. No one understands the things I’ve seen.”