FREETOWN, Sierra Leone—A sea of rusted, tin-roofed shanties cascades chaotically to the Atlantic. Between the makeshift shelters of Kroo Bay, a slum in the capital of Sierra Leone, people wash, cook, urinate, and repair roofs, radios, and engines.

White banners reading "Ebola: No Touch Am" ("Don't touch" in Krio, a creole language widely spoken in Sierra Leone) droop from crumbling walls—a reminder of the invisible killer ravaging the country, which spreads through bodily contact. It's an impossible command to follow in a place where families of six commonly share single rooms and two people cannot pass through an alley without brushing shoulders.

In December, more than seven months after the Ebola hit Sierra Leone, Kroo Bay was infested. The greater Freetown area had become the epicenter of the deadly disease.

At the end of a road to the settlement, a woman lying in the shade of a cinderblock building told me she had seen four people—potential Ebola cases—removed from their shelters that day. Government agents were sending the sick to recently constructed "holding centers" to wait for the results of Ebola tests. She said it sedately, and added that she was tired and hungry. We stared at the slums below and a sea clouded by Saharan dust.

In the beginning of September, there were 79 cases in the western region, including the capital. By the end of December, there were 2,766, a 35-fold increase. Officials were also worried then about a potential time bomb: A third of corpses recovered in homes had tested positive for the virus. Before those people died, they would have spent a week in the "wet" phase of the disease—sweating, vomiting, and bleeding—shedding virus-laden fluids that could have infected those around them.

When I met with Thierry Goffeau, the Sierra Leone country director for Doctors Without Borders, at a new Ebola treatment center in Freetown in late December, he looked weary. "We're more than six months into the outbreak, and Ebola might still rise in Freetown," he said. "That is not normal."

At that time, Sierra Leone, with assistance from foreign governments and nonprofit organizations, was still ramping up its response. It appears now to be working, as the spread of the disease slows there and elsewhere in West Africa. A close examination of what made Freetown so vulnerable to the outbreak offers critical lessons for the future in fighting Ebola or another major calamity.

Like many developing world cities, Freetown—population 941,000, the largest city in Sierra Leone—lacks the infrastructure to support its impoverished populace, making it prone to tragedy, whether through pestilence, violence, or natural disaster. Despite its congestion, Freetown continues to attract people who come in search of work, school, and the mere promise of electricity. It's no coincidence that typhoid and cholera regularly plague Freetown and that Sierra Leone's civil war climaxed in the city with horrific bloodshed.

Freetown's struggle against Ebola is unquestionably the result of its density and poverty. Further, inaction and ineptitude had allowed the situation to become dire. But an overlooked factor continues to complicate attempts to control the contagion.

In the varied quilt of the city—the concrete alleys of Kroo Bay, the littered riverbanks of Crab Town, the street markets of Waterloo, the shady woods of Devil's Hole—distinct social and cultural characteristics emerge.

To persuade many who live in these diverse pockets to take precautions against Ebola, outreach efforts must take these differences into account—a daunting task.

Ill-Equipped to Defeat Disease

Sierra Leone—wedged between Guinea and Liberia, the other West African countries badly hit by Ebola—acquired its name from a Portuguese explorer who arrived during the rainy season. Thunder roared over the jagged slopes where Freetown now lies, so he called the land Sierra Lyoa, meaning "Lion Mountain."

Two centuries later, Europeans docked along these shores to pick up slaves. Then, around 1790, ships dropped off freed slaves from Great Britain, Nova Scotia, and the West Indies on Sierra Leone's banks. They named their new home Freetown and settled beside Africans already there. Today, Freetown contains a mixture of people from various ethnic and cultural backgrounds, many of them traders, shopkeepers, and migratory workers on the move.

The health system in Sierra Leone, one of the world's poorest countries, had yet to recover from the ruination caused by its decade-long civil war when Ebola hit in May.

With two nurses for every 10,000 people—50 times less than the ratio in the United States—Sierra Leone ranks last, or near it, in many measures of well-being among more than 160 countries monitored by the World Bank and the World Health Organization. More women die in childbirth in Sierra Leone than anywhere in the world, and one in five children die before age five. The health situation in Liberia and Guinea also was awful, but not quite as dire; those nations reported nearly half the rate of maternal and child deaths as Sierra Leone.

Like the war that ended a decade ago, Ebola erupted in eastern Sierra Leone and burned westward before exploding in Freetown—where the ill-equipped city could not manage the disease. Patients were turned away from hospitals that lacked the beds and staff to treat them. Ambulances were so rare that the sick often died waiting for help.

Meanwhile, dozens of nongovernmental organizations that had been running health programs in Freetown evacuated the country en masse. Even after the World Health Organization declared the outbreak a "World Health Emergency" in August, international staff and donations only sluggishly translated into the capacity to handle the disease on the ground. When I arrived in early December, the region still lacked nurses, supplies, and beds for hospitals. In the interim, the death toll continued to mount.

We have been abandoned, Daniel Sesay, a university student, told me. He had been hired by the government to walk through Waterloo, a town on the outskirts of Freetown. He was instructed to dial the local Ebola hotline number—117—if he saw people with obvious fevers or other Ebola symptoms. He had done that, but often the ambulances never came.

"This is just like the war: When I call, no one comes, and the foreigners have run away," he said. We stood on the porch of a community center. Inside, sacks of rice and onions slumped against a wall, awaiting distribution to people cordoned off in their shanties for the 21-day incubation period of Ebola because they had come in contact with a person later diagnosed with the disease.

Fiona McLysaght, the Sierra Leone country director for Concern Worldwide, a nonprofit organization that had joined the government in the Ebola response, said, "The buildup has been painfully slow."

"It's System Failure"

In mid-December, I met O. B. Sisay, a slim, quick-witted Sierra Leonean who splits his time between London and Freetown, at the "Situation Room," which he directs. It's the hub of the country's National Ebola Response Center, or NERC. Several years ago, it was the room where trials against war criminals took place. Today, it is divided into sections: One corner is used for analyzing Ebola-related information streaming in from around the country, and another for responding to the data with adjustments to the attack on Ebola.

Sisay explained the Situation Room's process without pausing to inhale, and asked if we could talk over lunch—he said he kept forgetting to eat and had hardly slept since he assumed his role in November. When the United Nations offered him the job, he put aside his work for private clients who pay him to analyze risks, such as those posed by Somali piracy and kidnappings in the Niger Delta. This was his country, and he loved it and knew its weaknesses.

"The core crux of the problem is not Ebola," Sisay said. "It's system failure."

However, the system had finally ramped up and appeared to be close to capable. The number of centers to hold potential Ebola patients had doubled to 20 in the greater Freetown area. The number of beds for patients had nearly doubled as well, and a few dozen new ambulances had been put on the road. Ebola surveillance officers were telling me that, indeed, ambulances were arriving within a few hours of a 117 call. With the capacity in place, the outbreak—in theory—could rapidly be put in check as sick people were isolated in hospitals before the virus had a chance to spread.

Still, Sisay fretted about a final piece in the puzzle: attitudes. If feverish people did not call the ambulances and come to the clinics, the outbreak would continue. "People have lost confidence in the system because they were calling 117, and waiting three, four days for a response," he said. After watching a loved one die while waiting, would they ever call again? And those were the people who believed in the system in first place.

In an October survey, more than 10 percent of the people queried in the greater Freetown area said they'd continue to wash and touch the dead before burial, compared with less than 5 percent in other parts of the country. And 22.5 percent of those surveyed in and around Freetown believed spiritual healers could successfully treat Ebola, compared with about 10 percent of those elsewhere.

Since Sisay took his position at NERC, he had considered all of the potential reasons why the country's western region, which includes Freetown, accounted for over half of the cases when it has just a third of the population. Putting it bluntly, he said, city dwellers are stubborn, and the explanation for that has to do with the fabric of the city.

"Unlike most districts, where there is a homogeneous population," he said, "the western area contains a mishmash of people from all over the place. That matters because it affects people's propensity to change their attitudes."

Where he is from, a district in eastern Sierra Leone called Kenema, people tend to respect a handful of lifelong traditional leaders. There, he explained, "everyone does what the chief says, but here, in the western area, it's fragmented."

Traditional Chiefs Tackle Ebola

I went to Kenema seeking solutions for Freetown. Although Ebola had devastated Kenema—taking the lives of dozens of health workers and the country's only virologist, Sheik Umar Khan—the disease had nearly vanished by December.

On the five-hour drive from Freetown, I was required to stop at 12 checkpoints where young men brandishing infrared thermometers ensured that no one who had a fever was allowed to pass. And at the checkpoint outside of Kenema, a police officer scrutinized a pass I'd been given from the government to allow me to enter the town. Those without passes had a choice: turn back, stay in tents nearby for the standard 21-day quarantine period before entering, or offer an officer a bribe, an option too pricey for most Sierra Leoneans.

At roughly 200,000 people, Kenema's population is almost five times less than Freetown's. Most of the people farm, which means they can eat despite the checkpoints and quarantines that disrupt the trade that people in other parts of the nation rely on. Kenema's population is also not nearly as varied as Freetown's, and in general, people follow their traditional leaders. In addition to official districts overseen by political appointees, the eastern region is divided into chiefdoms firmly rooted in the past.

In Kenema, I met with the paramount chief presiding over the Nongowa chiefdom. Chief Alahaji Amara B. Vangahun sat on his porch in a white silk tunic and a decoratively embroidered skullcap. Two kittens played at his swollen, bare feet, and a dozen old men sat beneath a canopy in the yard.

The chief explained how, when the first mysterious deaths occurred in June, he consulted with a medical officer and learned about the dangers of Ebola. In response, he got on the radio to demand that his people isolate the sick and stop washing the deceased before burial. He even demanded an end to secret society rituals—clandestine ceremonies that permeate Sierra Leone. He worried that some of these traditional practices could spread Ebola through bodily contact.

"Five women were reported washing the [corpse of the] leader of their Bondo society," a women's secret society, "and we arrested them for eight days, and fined them 500,000 Leones [about $120 U.S.] each," Vangahun said to illustrate how seriously he had taken the threat, as well as the extent of his authority. My translator muttered, "The chief is the only person who could ever stop secret societies."

Mixed Response in Freetown

Back in the Freetown area, I met with headmen and counselors (elected, temporary leaders) who preside over various communities—only with far less sway. Several Sierra Leoneans explained that chiefs in rural regions of the country receive more respect than the city's temporary leaders because their lifelong roles are woven into traditional cultures. And my impression was that in return, some of the headmen and counselors didn't show much regard for their constituents.

In Tembeh Town, a dense cluster of concrete apartments clinging to terraces carved into a rocky slope, I met a counselor named Abdul Serry, dressed in jeans shorts and a white tank top. He emerged from a low doorway to speak with a surveillance officer, a college student hired to search for potential Ebola cases. A few men and women huddled close to eavesdrop on the conversation, while other women washing clothes in buckets in the alleyway looked on.

Serry told the surveillance officer, Alpha Kamara, that the community he led needed more rice, corn, and onions since restrictions during the outbreak had cut off his supply chains. Kamara jotted down the complaint. I asked the counselor what he thought of the country's efforts to squelch Ebola, and he shrugged and said, "In two or three months it will be gone." Then he and his companions filed back into the dark, hot apartment.

In other neighborhoods, however, a more promising response was evident. At Boyoh village, on the outskirts of Freetown, a headman named Sulaiman Kamara (no relation to Alpha Kamara) stood beside the road awaiting an ambulance he had called 20 minutes earlier. He seemed excited to have caught a potential Ebola case—a nauseated, fatigued woman who had stumbled into his territory. She sat crumpled beside the road in an oversize purple T-shirt.

In addition to reporting the woman, the headman told me he also was "observing a possible case." One of his neighbors complained of a sore throat, and although that's not a hallmark of Ebola, the headman vowed to not let anything slide.

There are villages around Freetown that can only be reached on foot, where clusters of shelters are lodged in crannies far up into the mountains. Just before New Year's Eve, a young Ebola surveillance officer told me that some people in these neighborhoods remained skeptical about Ebola.

"They had heard that you can catch Ebola by eating monkeys, and they said there weren't enough monkeys for them to eat—so they had no fear of Ebola," the officer explained. "Others had talked to the elders, and they said they know disease, and disease can't just come out of nowhere. So I told them this was something new, that it started in 1976 in the Democratic Republic of the Congo, and that it came here now through Guinea, and that it's very serious. It even kills our doctors."

In late December, the government launched "Operation Surge." Since then, agents have been going from house to house, seeking out the sick. "If we need to use force to bring people to the hospital, we will," said Mamoud Idriss, NERC's director of planning. "We cannot continue to run after Ebola," he explained. "The economy will crumble, people will get tired, and a lot of people will die."

The surge may be working. Today, the number of new cases in the greater Freetown area appears to be ebbing. In the first week of January, health officials reported 248 new Ebola cases in the country; between January 11 and 18, there were 117. When the outbreak is finally brought under control, the hastily constructed Ebola wards will vanish, and the city may be left as it was, only poorer. According to the World Bank, Sierra Leone will forgo $920 million in economic growth this year because of the outbreak.

Still, Freetown, like cities around the world, will continue to grow as people leave their traditional lives behind for the promise of the modern age. If their migration is not coupled with 21st-century infrastructure—toilets, paved roads, ambulances, and hospitals staffed by nurses and equipped with ample beds and reliable electricity—the capital will remain defenseless against disaster.

"Ebola is only the symptom, the disease is weak institutions," Sisay said. "If we have a flood or a tsunami, it will reveal all the same things."

Travel for this story was supported by the Pulitzer Center on Crisis Reporting.

Follow Amy Maxmen on Twitter and Instagram.