The virus had lurked for years, lacking only one thing it needed to inflict widespread human death: a perfect opportunity.

In late 1998, it got it. The virus arrived in central Malaysia by air, inside furry bats that alighted on the boughs of fruit trees swaying over pig farms. The bats, messy eaters, dropped their half-consumed meals. The swine, undiscerning eaters, gobbled up the leftovers. The virus, ready to move, hopped into the pigs and passed through their coughs to the humans who worked with them.

And within eight months, 105 Malaysians — about 40 percent of those infected — had died of this novel virus, dubbed Nipah, after suffering through fevers, brain inflammation and comas.

Scientists would piece together this chain of events, identify the virus and trace it to its origins in fruit bats over the years that followed — quickly for this sort of disease investigation. It took solid hunches, luck and painstaking detective work. That work is ongoing: Nipah erupts annually in Bangladesh, where it kills people at an even greater rate. It also occasionally infects people in India, where a 12-year-old boy died of the virus in September. There is no vaccine or cure.

But two decades later, as the world grapples with a pandemic caused by a type of virus that circulates in bats, the world’s first Nipah outbreak is still viewed as a case study in zoonotic disease spillover from animals to humans, the hunts for their sources and the importance of bats as incubators for a variety of pathogens.

Amid controversy and investigations about the origin of the coronavirus, it is the story of Nipah — and an encyclopedia of zoonotic diseases that includes rabies, West Nile, Ebola, HIV, MERS and SARS — that has led many scientists to argue that the most likely explanation is a natural spillover that occurred in the wild, not a leak from a lab.

This week, the World Health Organization unveiled an advisory group that will study the origins of the coronavirus and guide research to prepare the world against Disease X — shorthand for an unknown virus capable of causing human epidemics. Nipah, WHO officials wrote in the journal Science, was the Disease X of its time.

As much as 75 percent of new infectious diseases in humans are zoonotic, and spillover is happening with increasing frequency as a swelling human population comes into greater contact with wildlife and raises more livestock. That heightens the possibility of more-frequent pandemics in the future, scientists say.

“Probably every second, there are thousands and thousands of opportunities across the globe for a spillover event from a bat to a human. And yes, the vast majority of those fail,” said Montana State University infectious-disease ecologist Raina Plowright. “But if one in a billion doesn’t, maybe that’s enough for us to have another pandemic. … We have so many opportunities for cross-species transmission, and those opportunities are accelerating.”

In a recent report that has not undergone peer review, scientists estimate that tens of thousands, or possibly hundreds of thousands, of people in southern Asia are infected each year with bat coronaviruses related to SARS-CoV-2, the virus that causes covid-19.

And, in a separate report published before peer review, an international team of scientists say they have found the closest relatives to SARS-CoV-2 yet: a trio of viruses discovered in blood and other samples taken from 645 bats in Laos. There, in the north of the country, is an ecosystem of limestone caves — bat habitat — that stretches into south China.

Researchers are studying people in the area for signs of exposure to these viruses, said study author Marc Eloit, a virology professor at the Veterinary School of Maisons-Alfort and scientist at the Pasteur Institute in Paris. Workers in Laos gather bat dung for fertilizer, labor that may place them in proximity to bats in the caves.

Many scientists say they are not surprised the genesis of the coronavirus has not yet been untangled. It took researchers 14 years to trace SARS to horseshoe bats in southwest China. The source of Ebola, a deadly virus, remains unknown. And reconstructing a spillover event generally becomes more difficult as time passes.

“If you want to understand spillovers, you’ve got to be there in the moment,” said Emily S. Gurley, an epidemiologist at Johns Hopkins University who studies Nipah. “Once there’s a big event where everyone can observe it, the trail of how the spillover happened is usually cold.”

That coldness is the case, Gurley believes, for SARS-CoV-2. But in early 1999, the Nipah trail was still hot enough.

Special cargo

When the pig farmers began falling ill, the Malaysian government identified familiar suspects: mosquitoes. Public health officials thought these were cases of Japanese encephalitis, caused by a virus spread by mosquitoes that can also infect pigs but does not sicken them.

Massive mosquito-fogging campaigns were launched. Japanese encephalitis vaccines were administered. But people were still getting sick and dying. And unlike with most Japanese encephalitis cases, the victims were adults, mostly men who worked with pigs, some already vaccinated. Pigs were ill, too — coughing, mostly.

Amid the confusion, farms in the outbreak region sold pigs to operations farther south, including in a village called Sungai Nipah. The virus then broke out there. In March 1999, the mystery illness also surfaced among slaughterhouse workers in Singapore who processed pigs imported from Malaysia.

“We still didn’t know how serious the virus was. … We were still trying to save the pigs, injecting medicines in them,” recalled Pau Jeou Ching, who at the time was the 14-year-old son of farmers who kept 1,000 pigs on two acres in Sungai Nipah. “But after some time, we saw that the pigs were still very sick and that something is not so right. When people started dying, then we started to panic.”

Soon, he and his father fell ill. Pau recovered. His father, 53, did not.

In Kuala Lumpur, Kaw Bing “Paul” Chua, a researcher in virology at the University of Malaya, watched with worry, suspecting this wasn’t Japanese encephalitis. But his superiors disagreed, and he had little clout. So when Chua’s lab got a call about testing spinal fluid from a patient from Sungai Nipah, he “tricked” his boss, telling him he would test it for other types of Japanese encephalitis, Chua told The Washington Post in an email.

Instead, Chua exposed lab-grown mammal cells to the patient sample. Using a microscope, he spied that those cells had clumped together — not a reaction the virus responsible for Japanese encephalitis was known to cause. A few days later, Chua exposed new patient samples to this peculiar virus, which he had isolated. If those patients had developed antibodies that target this virus — meaning they too had been infected by it — the sample would light up green.

Chua again peered into his microscope, and, he later wrote, felt a “chill going down my spine.” The slide glowed green.

Chua knew he needed a powerful electron microscope to identify the virus — and for that, he would need to go overseas. Days later, he was on a plane, bound for a Centers for Disease Control and Prevention facility in Colorado that studies mosquito-borne viruses. The deadly pathogen was in his carry-on, packed according to international safety standards. Chua was not worried. “In fact, I knew and [was] confident what I [was] carrying was the answer to solve the outbreak,” he said by email.

He was right. The electron microscope revealed a ringlike shape characteristic of a paramyxovirus — a family that includes measles, mumps and respiratory illnesses, but not Japanese encephalitis. Chua was overcome by sadness, because this told him the virus was transmitted not by mosquitoes, but livestock — the pigs. He immediately called his boss in Malaysia.

“Most likely it is a new paramyxovirus. The control measures for paramyxovirus are totally different from Japanese encephalitis virus. Please! I want you to urgently pass this message to the Ministry of Health,” Chua told his boss, according to a personal account he published in an academic journal. “All I could think of at that time was the unfortunate pig farmworkers.”

An international team arrived in Malaysia to investigate. Among them was Hume Field, an Australian veterinarian and PhD student. He’d helped crack the case of another mysterious virus a few years before, one that killed a couple dozen horses in Australia and two people. It, too, was a paramyxovirus. That virus, Hendra, was traced to fruit bats.

That made fruit bats, or flying foxes, a prime target in Malaysia. But the disease detectives would need to consider other suspects. They went to the farms where the virus broke out, and where fear was still palpable.

“People would tell us they knew when it was in their area, because they could hear the pigs cough. It was referred to as a one-mile barking cough — you could hear it a mile away, and you could hear it coming closer and closer to your piggery, and you knew that you were going to be next,” Field said.

The team tested wild boar, dogs and rats near the farms. Nothing. Same for the first groups of fruit bats they captured with tall nets. But they kept going, and eventually found significant antibodies to the new virus in two species — the Malayan flying fox and the island flying fox. This was strong evidence these bats were natural reservoirs. But it wasn’t proof.

At the pig farms, meanwhile, the government had adopted a new method to stop the outbreak: mass culling. One million pigs were killed that spring, crippling the pig industry. But the disease was stopped — temporarily.

Two years later, Nipah virus — named for the sample Chua used to isolate the virus — would find new opportunities.

‘Every minute of every day’

Zoonotic pathogens need just that to leap from species to species: opportunities. Those pathogens also need the right tools to invade other animals — a category that includes humans.

To infect a person, a zoonotic pathogen must avoid or penetrate many barriers, Plowright and other researchers wrote in 2017. Among the necessary steps: An infected animal must release the pathogen in such a way that it survives and spreads, perhaps in another animal. The virus must encounter a person and slip through physical human defenses, such as skin.

Once inside a human body, the virus must be able to defeat the immune system — which is not a certain outcome, because immune fighters can thwart many would-be invaders.

And a new virus needs the ability to sneak inside a human cell. The novel coronavirus, for instance, does so via specialized spike proteins. These attach to the surfaces of human cells and, akin to skeleton keys, permit the pathogens to enter. This is yet another potential barrier: A virus’s keys must be compatible with the locks in human cells.

But if an invader is successful, it can hijack the interior machinery of a cell to churn out copies of itself. In a new species, replicating viruses swap genetic material like trading cards, developing new features that may make them stronger or weaker, or able to infect other animals.

Most viruses that live in other species do not pose a threat to humans, because those pathogens cannot reproduce within people. “But on occasion, you get one that can replicate quite nicely — and, worse, transmit,” said Tony Schountz, an expert in bat-borne viruses at Colorado State University.

It has happened, again and again. Measles split off from a related cattle pathogen as early as the 6th century B.C. HIV is believed to have originated from a virus that afflicts chimpanzees. This spring, researchers detected a new coronavirus in Malaysian children who had pneumonia — a chimera of sorts, similar to a coronavirus in dogs, but with signatures of feline and porcine coronaviruses as well.

Humans are facilitating these events, scientists say. We encroach on wild habitats, getting closer to wildlife. Trade of exotic species brings together animals that would normally never meet. A recent Scientific Reports paper described more than 47,000 wild animals sold in markets in Wuhan, China, in the two years before some of the first covid-19 cases emerged there.

Bats, ancient creatures that make up 25 percent of all mammal species on Earth, have an array of attributes that make them particularly good reservoirs. For starters, they seem generally unscathed by disease. Why is unclear, but some scientists hypothesize that their ability to fly — unique among mammals — depends on an immune system that suppresses inflammation, a typical mammalian response to infection.

Bats, from grasshopper-size species to flying foxes with five-foot wingspans, can also live two decades or more. They roost in enormous groups. Some, like flying foxes, travel hundreds of miles and mix with other bats. All this helps them transmit disease among each other. Unlike Nipah and its family of viruses, of which about five or six are known to circulate within bats, more than 1,000 different types of coronaviruses exist in bats.

“There are so many of these viruses out there waiting to get together in a bat where they can then exchange genetic information,” Schountz said. “That could then lead to new genotypes of coronaviruses that could cause another disease outbreak, or maybe not. Who knows? This is a game that nature is playing every day, every minute of every day.”

By 1998, Malaysia had undergone an economic boom that led to a greater demand for meat, and more forests cut for agriculture. Some pig farms, previously a backyard industry, had tens of thousands of animals. Some farmers supplemented their income with fruit orchards, planting trees next to open-air pigsties — perfect flying fox buffets.

The virus amplifier

The Nipah outbreak in Malaysia ended in May 1999. But researchers still were not certain how it started. Knowing Nipah antibodies had been found in two species of flying foxes, Chua and a team headed that summer to the home of one: Tioman Island, off the east coast of peninsular Malaysia.

As the team later described in a paper, the flying foxes urinated and defecated “vertically downward” right after returning from nightly meals. So at dawn, just before the bats came home to roost, Chua’s team spread plastic sheets under their trees, collecting urine. At night, the researchers visited the bats’ feeding grounds. As soon as the flying foxes dropped their mangos and water apples, the team members swabbed the fruit.

On their first visit, the team found a new virus that they named after the island — but no Nipah. None on the second trip, either. By the third, they had collected hundreds of urine samples and swabbed dozens of fruits. And finally, in just three of the last samples, they found it. Genetic sequencing confirmed it: These flying foxes were reservoirs for the Nipah virus.

But the island species, Pteropus hypomelanus, is not the species that lived near the mainland pig farms. That was Pteropus vampyrus. Why did it emerge on the farms? Did other bats carry Nipah? Was it common in bats? Was it a new virus, or did something trigger the spillover of a virus that had been there all along? How did bat colonies interact?

Jonathan Epstein arrived in 2003 to lead a team focused on answering those questions. Epstein, who is now vice president for science and outreach at EcoHealth Alliance, a nonprofit that researches emerging diseases, had studied a rabies-like virus in bats a few years before, when rabies was thought to be the primary threat carried by bats. The discovery of Hendra and Nipah viruses had shattered that notion.

The team captured and took samples from flying foxes across Malaysia. To some bats, they attached little leather collars affixed with satellite telemetry transmitters, which had been tested on captive bats to ensure they didn’t fall off when the animals hung upside down. They microchipped other bats, so they could track them over time.

The team found the bats had an “incredible range,” Epstein said, sometimes flying to Indonesia. They found Nipah antibodies in nearly every colony of Pteropus hypomelanus and Pteropus vampyrus, but not in other fruit and insect bats. And they found hardly any live virus in many hundreds of samples.

“That revealed that this virus circulated widely in bats, as evidenced by the rate of exposure, but very infrequently in individuals, because it was so hard to find live virus,” Epstein said. That meant spillover would be very rare.

What’s more, the virus seemed to come and go within colonies, but not seasonally, and not in sync with pregnancy or lactation. Later, Epstein and colleagues would find that bats lose herd immunity over time, allowing the virus to persist.

This information and other studies had by now given researchers confidence to draw a conclusion without actually witnessing the spillover. Bats had passed this new virus to pigs via discarded fruit, and pigs served as excellent amplifiers.

On large farms, “there’s a constant influx of new, naive pigs in the form of piglets being born. Viruses depend on susceptible individuals,” Epstein said. If Nipah is introduced repeatedly, then “you get a slow, long sustained outbreak of Nipah virus that sticks around in this pig population.”

Some pigs died of the virus, but most did not. When farmers in central Malaysia sent pigs to other areas such as Sungai Nipah, the virus went with them.

A sweet drink’s misery

In 2001, Nipah emerged again, this time in Bangladesh. Outbreaks have recurred almost every year since. Here, it was different: In the Muslim-majority nation, there was little pig farming. Patients had more respiratory symptoms. And alarmingly, it seemed to be transmitting from human to human — and killing 75 percent of its victims. Scientists found it was Nipah, but another variant.

Little was clear about those first outbreaks, said Gurley, who has been studying Nipah in Bangladesh since 2004. Shortly after she arrived in the country, there was another outbreak, mostly in children who lived in adjacent villages but otherwise had no common link. Three months later, another big viral infection cluster erupted.

“We identified maybe 15 suspect cases on the first day,” Gurley said. All of those cases had contact with people who died of the same illness. Nipah wasn’t necessarily assumed to be the culprit. “Everybody was still freaked out about SARS in Asia,” Gurley said.

For the remainder of 2004, Gurley and her colleagues began to catalogue all the ways humans came into contact with bats in Bangladesh — or bat secretions or anything that the animals might have touched. On that list was date palm sap. This sweet drink is harvested similarly to maple sap, collected in pots hung from trees overnight, then consumed fresh in the morning.

In 2005, there was another outbreak. And this time, there was a smoking gun.

The 12 patients lived in several different villages. Eleven died. None had contact with another patient. There was no evidence of person-to-person transmission.

But the investigators found the villages weren’t as separate as they seemed — they shared an edge along a main road.

“Someone had fresh sap and came through the main road, selling a glass at a time,” Gurley said. Many of the sick patients had consumed date palm sap that had been collected in the same pot, sold by the same vendor.

As research using infrared cameras would later confirm, bats lapped up the sugary liquid — and shed Nipah — as it flowed into date palm sap collection pots. Humans became infected by drinking the contaminated sap.

But it has not solved every mystery of Nipah in Bangladesh. Nipah infects humans in one part of the country more than others, even though date palm sap consumption is widespread. Outbreaks happen more frequently during Bangladesh’s colder winters. Gurley and her colleagues do not know why.

“We know so much about Nipah. But there are so many unanswered questions,” Gurley said. “What we do know — that’s taken a long time. It’s much longer than any research grant. It’s longer than anyone’s tenure in a particular job.”

There was a large Nipah outbreak in Kerala, India, in 2018, where date palm sap is not consumed. “How did that spillover happen? We have no idea,” Gurley said.

Researchers do know this: Nipah is evolving, said Epstein, who also studies the virus in Bangladesh. So far, Nipah is astoundingly lethal but not particularly adept at human-to-human transmission.

“What if there are genetic variants already in bats that are more adapted to people already — more able to spread efficiently from person to person?” Epstein said, describing a terrifying scenario that inspired the 2011 movie “Contagion.”

“That is the single most important reason why we are paying so much attention to Nipah virus.”

‘People here are very alert’

Since the last death in May 1999, there have been no Nipah outbreaks in Malaysia. But the epidemic left scars.

That spring, the Malaysian government evacuated the region around Sungai Nipah, the nation’s pig-farming epicenter. The army moved in to kill pigs. Pig farming remains banned in the area, and many producers converted their farms to palm oil or dragon fruit operations.

Pau, the then-teenaged farmboy, moved back to the area, where today his mother and sister cultivate palm oil. Pau, now the 36-year-old director of a party supply chain, manages the Nipah Time Tunnel Museum in the village, which he co-founded in 2018 in hopes of attracting tourists. It tells the story of the outbreak, and he said about 5,000 people visited in first couple years.

Then, a new epidemic hit — the novel coronavirus. The museum has been closed for more than a year. But village residents are taking things in stride, Pau said.

“Because of our Nipah incident 21 years ago, people here are very alert with covid-19,” Pau said.

They don’t want the region to be shut down again. And they don’t want another deadly virus to spread.

Emily Ding in Dubrovnik, Croatia, contributed to this report.