It seemed like the nightmare scenario: Ebola had reached Africa's biggest city, a chaotic and densely populated metropolis of slums and shantytowns where the virus threatened to spread to millions of people.

(Read The Globe's primer on West Africa's Ebola outbreak)

Health experts were terrified when Ebola struck Lagos in late July. They were deeply worried that it would be unstoppable in Nigeria, a rapidly urbanizing country of 170 million, far bigger than the nations where Ebola had begun. Their fears were heightened in August when the virus leaped another border and reached Senegal, another key West African country.

Story continues below advertisement

Yet today, in a remarkable display of how to beat the lethal virus, both Nigeria and Senegal have defeated their Ebola outbreaks. The World Health Organization announced on Friday that the outbreak was officially over in Senegal, and made the same declaration for Nigeria on Monday. In both countries, 42 days have passed since their last reported case – the standard rule for declaring an outbreak over, since it is twice the maximum 21-day incubation period for the virus.

"The most important lesson for the world at large is this: An immediate, broad-based and well-co-ordinated response can stop the Ebola virus … dead in its tracks," the WHO said on Friday after declaring the end of the Senegal outbreak.

Based on the successes of Nigeria and Senegal, here are the strategies that can be adopted by other countries, including the United States and Canada, as they prepare for the threat of the virus.

Rapid response to the first case

Nigeria's first Ebola patient, Patrick Sawyer, was initially thought to have malaria. But when malaria treatment failed at a local hospital, doctors immediately began treating him as a possible Ebola patient, and he was kept in isolation at the hospital. Officials were notified and a blood sample was rushed to a testing lab.

On July 23, just three days after Mr. Sawyer arrived in Lagos on an indirect flight from Liberia, the Nigerian health ministry set up an Ebola Incident Management Centre, which evolved into an Emergency Operations Centre to co-ordinate the response and the decision-making.

The centre took over the management of each suspected Ebola case. It investigated every possible case and supervised the decontamination of their homes. Each suspected case was isolated in a special ward of a treatment facility. Blood tests were rapidly conducted to verify if suspected cases were genuine or not.

Story continues below advertisement

Senegal, meanwhile, had been well-prepared with an Ebola response plan as early as March. It created a National Crisis Committee as the "nerve centre" for its response, and deployed its emergency plan nationwide in August, even though only a single case had been detected. "The whole country moved into a heightened state of alert," the WHO said.

A rigorous and relentless system of contact-tracing

Nigerian health teams visited 18,500 homes in Lagos and Port Harcourt, the two cities where Ebola cases were reported, as they searched for anyone who had been in contact with the 20 Ebola patients in the country. More than 150 contact tracers were deployed.

The tracing teams tracked down 894 people who had been in contact with Ebola patients, and began monitoring their health closely. The WHO described it as "world-class epidemiological detective work." Even mobile-phone data and law-enforcement agencies were employed to trace contacts, using an emergency presidential decree, and airplane manifests were scrutinized. Health workers visited any contact who reported symptoms – or who failed to provide health updates via cellphone text messages.

In Senegal, tracers found 74 close contacts of the country's sole Ebola patient. The health of each of these 74 people was carefully monitored, twice a day. To encourage their co-operation, the contacts were offered food, money and psychological counselling.

An energetic campaign of public education

Story continues below advertisement

In Nigeria, social mobilization teams went house-to-house to visit 26,000 families who lived within two kilometres of the Ebola patients. They explained Ebola's warning signs and how to prevent the virus from spreading. Leaflets and billboards, in multiple languages, along with social-media messages, were used to educate the broader Nigerian population.

Education was crucial in a country where dangerous myths were spreading. There was even a rumour that drinking large amounts of salt water would protect people from Ebola – a rumour that sickened and even killed some Nigerians who attempted the harmful diet.

Senegal, too, created a national public-awareness campaign, using media experts and local radio networks.

Effective public-health institutions

Senegal and Nigeria both benefited from a stronger and better-financed system of public health than Liberia, Sierra Leone and Guinea, the impoverished countries where the current epidemic began.

Nigeria also took advantage of the infrastructure of a polio eradication program that had been active for years. A polio and HIV clinic in Lagos, financed by the Gates Foundation, was transformed into an emergency centre for Ebola, with dozens of doctors available.

Story continues below advertisement

Nigeria was also quick to welcome foreign help. There was remarkable co-ordination between every level of Nigerian government and global health organizations such as the WHO, the U.S. Centers for Disease Control and Prevention, and Médecins sans frontières (Doctors Without Borders). Private companies donated ambulances, disinfectant and other important supplies.

Heightened vigilance and screening at borders, but a refusal to halt air travel

Nigeria and Senegal boosted their surveillance for Ebola, especially at land border crossings, but they never closed their airports.

"Critically important early on was the government's decision to open a humanitarian corridor in Dakar to facilitate the movement and activities of humanitarian agencies," the WHO said. "This decision meant that food, medicines and other essential supplies could seamlessly and efficiently flow into the country."