DADAAB REFUGEE COMPLEX, Kenya — Mohamed Omar Abdille remembers the night before he left his home in Merca, Somalia, in September 2012 to begin life as a refugee.

He was 15. Family and friends gathered around the table for a final meal before his departure. His mother served his favorite supper of spaghetti, beef and milk. They joked and laughed about his journey ahead and spoke of the peace that prevailed at the Dadaab refugee complex, 325 miles away in Kenya, and about the opportunities that awaited Mohamed there. An uncle was already at one of the five camps at the complex, and Mohamed could live with him while he attended school. In Merca, Mohamed recalled this past summer, “there was little food or water, and the few schools had long been closed.”

As the family and visitors ate, they could hear gunshots and explosions from the ongoing battles between clan factions across town. The Somali government’s war against al-Shabab, the terrorist group affiliated with al-Qaida, also afflicted Merca. Mohamed’s siblings wished they could go with him; he assured them that once he had an education he would be back to teach them, too.

Mohamed’s father, Omar, a shopkeeper and a farmer, would have liked to take the whole family to Dadaab, but he couldn’t afford the $50 per person it would cost to shuttle them there by private van from Merca. Failing that, he wanted Mohamed, as his eldest son, to go to school; the rest of the family would move to Barawe, 60 miles down Somalia’s coast, soon after Mohamed’s departure.

After finishing the meal at 11 p.m., the family retired. Excited to start his new life, and kept awake by distant explosions, Mohamed, who shared a mat with his six-year-old brother, could hardly sleep.

“Finally, I was going to learn English,” he said.

Before dawn the next morning, his parents took him to the bus stop. His father gave him the $50 fare. His mother, handing him cakes she had baked for him to eat on the way, told him, “You will not be lonely — your relatives are there. Your uncle will take you to school. Do not think of me so much.”

After saying goodbye to his parents, Mohamed could not get a seat inside the white Nissan Homy van and had to sit on the roof. Four days of travel on dusty, bumpy roads brought the van to Dadaab.

Officials from the U.N. High Commissioner for Refugees (UNHCR) processed Mohamed’s registration, and he was able to find his uncle. Soon he would enroll in primary school at Hagadera refugee camp. In Somalia, he had attended an informal school, known as a duksi, where the students only learn the Koran. His 11 siblings have never received proper schooling.

Today, Mohamed is back in Somalia — among the first refugees to be repatriated at the demand of Kenya’s government. The Dadaab refugee complex was established in 1992 when civil war engulfed Somalia following the fall of dictator Mohamed Siad Barre. Drought and regional conflicts in the ensuing decades caused the complex to grow by 2011 to a peak population of 565,000 in camps built to accommodate 90,000. Dadaab now offers a haven for refugees from every country that neighbors Kenya — Somalia, South Sudan, Ethiopia, the Democratic Republic of Congo, Tanzania and Uganda — as well as Rwanda. According to UNHCR, Somalis make up 95 percent of the camp’s population. About 80 percent are women and children.

The Dadaab refugee complex grew to half a million residents but was built to house 90,000. (IMAGE: TONY KARUMBA / AFP / GETTY IMAGES)

At Dadaab, refugees have found not only safety but also education, health care and business opportunities — all in short supply in parts of the region, especially Somalia. The U.N. runs the camps, and humanitarian agencies assume various functions, operating schools, doling out food rations, managing water and sanitation, and offering programs in gender-based violence. About half of Dadaab’s 168,745 children between the ages of three and 18 attend school — a much higher enrollment rate than Somalia’s — according to Lennart Hernander, program representative for the Lutheran World Federation in Kenya and Djibouti, which runs schools at Hagadera camp, including the one Mohamed attended.

But refugees in Kenya faced increased pressure after attacks by Islamist terrorists, angry over a joint operation of the Kenyan and Somali militaries against al-Shabab in 2011, began to strike civilian targets in the country in 2012. A Kenyan official told reporters in 2013 that one of the attackers on the Westgate shopping mall that September had passed through a refugee camp in Kenya’s northwest. A voluntary repatriation program was begun in December 2014. When al-Shabab killed 147 Kenyans at Garissa University College in 2015, Deputy President William Ruto announced that Dadaab would be closed within three months.

Few took the threat seriously; forcibly repatriating refugees to a country where their lives would be in danger is a violation of both Kenyan and international law, and Nairobi’s human rights commission opposed the idea. But as peace returned to segments of Somalia, Kenya’s claims that security, high costs and lack of support from the international community were weighing on the developing nation began to resonate. The population of Dadaab was falling — down 40 percent, by some estimates, between 2011 and 2016 — but not fast enough for officials in Nairobi. In May 2016, the government renewed calls to close Dadaab.

“At great cost, our troops have liberated large swaths of Somalia from the hold of al-Shabab, yet we are still presented with a picture of a country to which none of its refugee diaspora can resettle, while U.N. workers traverse much of that liberated country with relative safety,” wrote Kenya’s principal secretary for the interior, Karanja Kibicho, in a statement in May.

In June, UNHCR agreed to a plan to resettle 150,000 residents by the end of 2016.

From the start of the voluntary repatriation program through August, Somali refugees totaling 29,371 had been repatriated from Dadaab, according to Duke Mwancha, a UNHCR spokesperson in Nairobi. Convoys of up to 11 buses carrying 70 people each leave as frequently as four times a week.

When he was not attending school, Mohamed learned how to use a computer at the youth center at his camp. He enjoyed playing soccer with schoolmates and visiting friends elsewhere in the complex. After school, he would help out at his uncle’s shop, where he sold foodstuffs such as sugar and flour. The camp offered opportunities for children to learn and grow, but finding a job, winning a scholarship or getting resettled in a new country depended on luck.

“All children have an opportunity to go to school, but not everyone who finishes school can get work or be resettled,” Mohamed said.

When Mohamed first heard over the radio in May that the government of Kenya planned to repatriate all Somali refugees, his first thought was that it would never happen. (Many observers shared his belief.) Many in the camps, especially those who had been there for years or were born there, dreaded the idea of being forced to go to Somalia. But the June announcement to resettle 150,000 residents seemed a more realistic goal. Though not unhappy at Dadaab, he felt that it was only a matter of time before he was sent back. He imagined he could continue his education in Somalia despite the precarious situation.

The U.N.’s facilitating the return of refugees meant he wouldn’t have to ask his father to pay for his transportation. His uncle had been resettled in the U.S. in December 2015, moving to Utah with his immediate family, so Mohamed was losing his ties to Dadaab. He had made something of his time at the camp, having obtained a Kenya Certificate of Primary Education, and was ready to move on.

His father agreed that Mohamed should continue his studies back home. Though the boy planned to live in Mogadishu, Omar told his son of schools that had opened in Barawe, and that the small city was seeing a degree of reconstruction.

Early one morning toward the end of June, Mohamed set off to the UNHCR field office, a few hundred yards outside the Hagadera camp he had called home for nearly four years. He walked among the many mud-walled, tarpaulin-roofed structures of the camp, past the crowded market, to the warren of humanitarian organization offices.

Around 700 refugees were already outside a gate manned by private security guards. A queue snaked out along the razor-wired perimeter fence toward the market. Many were there to register for voluntary repatriation, taking advantage of the offer of free transport and assistance with resettlement once in Somalia.

A private security guard contracted by UNHCR used a tree branch as a whip to keep refugees from crowding the entrance to a hall where officials processed repatriation documents. (IMAGE: ANTHONY LANGAT / TAKEPART)

Others had completed registration and were back for the mandatory health screening. Mohamed explained himself to the guards and was allowed in. After hours of waiting in line, his registration was completed quickly. A week later he completed his health screening.

On the morning of July 18, Mohamed was called with other refugees to move into the transit camp UNHCR had set up at Hagadera in preparation for transfer to Mogadishu. They were informed they would be flown out in a week. Mohamed was thrilled at the prospect of boarding an airplane for the first time.

But on the morning of the scheduled flight, al-Shabab struck U.N. and African Union buildings near Mogadishu’s Aden Adde International Airport with twin suicide car bombs, killing 13 people and injuring five others. Repatriation flights and bus trips to Somalia were suspended indefinitely. What should have been a short stint at the transit center would become weeks, and patience among the refugees ran thin. At times, crowds would push and surge forward to the gate and be whipped with long canes wielded by guards in white shirts, blue trousers and black boots. Mohamed said he saw a woman, whom he estimated to be about 70 years old, beaten by the private guards contracted by UNHCR for skipping the queue.

“We just want to go home. Why should they keep us here and beat us, yet it is our homes we want to go to?” said a woman who witnessed a beating in late July.

Food rations in the transit camp were irregular and inadequate, Mohamed said. Men would often forgo their rations so women and children could be fed.

“Sometimes just white rice is brought in, and sometimes we get only tea in the morning and nothing else until the next day,” Mohamed said.

Many evenings he would walk to Kambioos, a refugee camp three miles away, in the evening for supper with a friend who would share with him. (Ishmael Mohamed, UNHCR repatriation officer at Hagadera, said refugees at the transit center had access to two hot meals every day provided by a local contractor.)

Mohamed Gaab Hassan, a father of three from Kismayo, Somalia, waits at a transit center with his wife and one of his children. (IMAGE: ANTHONY LANGAT / TAKEPART)

Mohamed Gaab Hassan, 40, a father of three from Kismayo, Somalia, was at the transit center with his family at the same time as Mohamed. He and his wife and children left home for Dadaab in 2011 after all his 150 goats and 10 of his 20 camels died because of drought. He left the remaining camels with his mother and brother and crossed the border for Dadaab, where he was pleased to find that his children could attend school.

When the repatriation effort was announced, Hassan decided to go home to his aging mother. After he was told he and his family would be sent to Somalia, officials informed him their papers had to be reviewed because his daughter had decided to stay. The 14-year-old married a fellow refugee in January and said she and her husband wanted to stay longer at Dadaab. Hassan and the rest of the family couldn’t be released until the necessary paperwork was processed to show that his family was now less one.

“I do not have any issues with my daughter choosing to remain behind with her husband, but I wish they could clear this up quickly so that my family and I can go home,” he said through a translator.

His camels now decreased to five, he was eager to go back and help his mother.

Two weeks after the al-Shabab attack, trips to Somalia picked up again — but not to Mogadishu. Mohamed had to wait for the flights to resume. A few days later, it was decided that the refugees who were to be flown to Mogadishu should choose other towns, where they could be taken by bus.

“We are focusing on the peaceful areas and regions where we have a UNHCR presence,” said Ishmael Mohamed, of the UNHCR.Mohamed Omar Abdille chose Kismayo, a coastal town 325 miles southwest of Mogadishu, where an aunt lived. From there he could catch a private bus to the capital. After another false start, he was among 700 refugees set to leave on Aug. 11.

Kenyan officials were at the Dadaab airstrip early that morning to prepare documentation for the refugees. Half a mile outside the camp complex, on the outskirts of the town of Dadaab, the airstrip is a wire-fenced runway without a single building. UNHCR and government officials processed papers while seated on plastic chairs inside tents.

At 8:30 a.m., hundreds of refugees waited to be cleared. Government and UNHCR officials issued repatriation forms, convoy tickets and cash — $200 per individual to help with getting settled. The sick or people with disabilities received $230.

Both Mohamed and Hassan were among the last to be cleared, around 2 p.m. Mohamed beamed as he received his money and a parcel containing his repatriation documents.

Half an hour later, the convoy left the airstrip. Two police vehicles led the way, followed by 11 buses, with other police vehicles bringing up the rear. After two hours of traveling, the convoy arrived at Dhobley, a border town. That was as far as the Kenyan buses and police escort could go; despite Mohamed’s understanding that he would be taken to Kismayo, everyone was told to debark at the border.

The refugees crossed into Somalia, where they were now on their own. Privately operated Nissan vans awaited to take them to points inside Somalia. Mohamed paid $20 for transport to Kismayo, where he arrived two days later. He went straight to his aunt’s house, near the main market.

He planned to stay a few days and report to the UNHCR office before continuing on his journey to Mogadishu, where he hoped to find a good high school.

“The UNHCR has promised to pay fees for us to continue our education here in Somalia,” he said by phone. At the office, he was given an additional $200. He decided to send $100 to his mother using a mobile money transfer service.

A lot had changed in Kismayo since the last time Mohamed was there. He saw buildings under construction and schools and hospitals and other public buildings being rebuilt.

“It is peaceful here, just like it is in Dadaab,” he said. “There are no gunshots. There is no war. You can walk around town even at midnight.”

Mohamed spent four days with his aunt. A week after leaving Dadaab, he boarded an airplane for the first time and flew to Mogadishu. He stayed with a cousin who runs a mobile phone shop on the outskirts of the city. Unlike in Kismayo, Mohamed was stopped by intelligence officers and police, who asked for identification and checked anything he was carrying with him.

“It is because they are always on the lookout for al-Shabab, but apart from that I find Mogadishu to be peaceful,” he said.

Mohamed’s father feels differently about conditions in Mogadishu, and asked his son to abandon his plans of finding a school there to attend.

“On my second day here, my father called me and told me to look for a school in Barawe instead,” Mohamed said. “He said that as his firstborn son, he wants me to be near him to help him out with the business when I am not in school.”

Mohamed felt he had no choice but to head home, as his father had asked him. He found a bus to Barawe and arrived at his mother’s house just in time for supper. (His father now lives nearby with his second wife.) Rice and beef were served, and it was all happiness as he ate with his family and related for them how life was in Kenya. His siblings were particularly interested in the experience of air travel.

“No one in my family has ever boarded a plane, and they are really excited about it,” he said.

On his second day at home, Mohamed started looking for a high school to enroll in. He wasn’t happy about the schools in Barawe as compared with what he had become accustomed to in Dadaab.

“I will still speak to my parents to see if they can allow me to go and find a school in Mogadishu,” he said.

Hernander, of the Lutheran World Federation, is concerned that the repatriation will have an effect on the school-going children’s education.

“Children who move from a country to another will inevitably be affected by a change in the school system,” he said. “Moving from a well-established system with decades of development behind it like Kenya to a new system being under continuous development and most likely with far less resources, less experienced and less trained teachers, and maybe less capacity to enroll children at all, is likely to have negative impact to the children’s education.”

He believes development of a national education system in Somalia is essential to Somalia’s capacity to absorb returnees.

Despite his difficulties finding a suitable school, Mohamed is happy to be home. He hopes peace will return to the rest of the country, and that services such as education will be improved. His wish is to attend university after high school.

Then, he said, “I want to work for the government. I want to be able to assist my fellow citizens get access to government services. I have seen how hard it is for an ordinary citizen to access services, and I want to change that,” he said.

Two weeks after Mohamed left Dadaab, authorities in the region where he now lives, Jubaland, suspended the reception of more returnees, citing lack of capacity. There have been no road convoys to the border since early September, though flights to Mogadishu now depart twice a week. Mwancha, of the UNHCR, expressed confidence that Jubaland’s new policy would be temporary, and that convoys would resume once more humanitarian assistance was in place. (Already, 4.7 million people require food aid in Somalia, with the number to rise if a two-year drought continues, according to the U.N.)

Until then, he said, the 1,000 people ready to be taken to Dhobley on the day the suspension was announced will be waiting at the transit centers at Dadaab.