The yellow fever virus lurked deep in the Amazon jungle until around July 2016 when it leapt toward the highly populated south of Brazil, carried by monkeys and the mosquitoes that liked to bite them.
At a speed of about two miles (3.3 kilometers) per day, the virus made its way to the outskirts of the big cities of Sao Paulo and Rio de Janeiro, places it had not circulated in decades, and where more than 35 million people were not vaccinated against the illness.
Two years later, 676 people were dead in the worst epidemic of yellow fever in Brazil in a century.
Yellow fever can kill a person in less than 10 days, wreaking havoc on the body with symptoms like jaundice, abdominal pain, vomiting, and bleeding from the mouth, nose, eyes and stomach.
Now, for the first time, the virus's path has been retraced in detail by an international team of scientists, and experts say this new genetic and geographic mapping could help fight future outbreaks of the disease.
"This is the first time that we are able to estimate how rapidly the virus is moving in space and time," said Nuno Faria, professor in the zoology department at Oxford University, co-author of the study in the journal Science.
Their work rules out the long-feared hypothesis that yellow fever was jumping from person to person — via the bites of Aedes aegypti mosquitoes — in an urban environment.
Instead, the latest outbreak was carried to people by wild jungle mosquitoes that had previously bitten contaminated monkeys.
The people infected — 85 percent of them men in their 30s, 40s and 50s — lived or worked within a few miles of the jungle habitat of these monkeys.
Researchers tracked the movements of the virus by noting when and where monkeys, and then people, began to be contaminated and turn up dead.
Cases among monkeys tended to precede humans by about four days, they found.
But the virus moved even faster than the monkeys did, which suggests that people had a role in moving the disease to new areas, such as by illegally trafficking monkeys or driving vehicles in which mosquitoes had hitched a ride.
Analyzing the genomes of people and monkeys that were infected confirmed the source of the epidemic.
Researchers say this combined method could help better tailor real-time responses to future outbreaks.
"It's high-end work," David Hamer, professor of global health and medicine at Boston University, told AFP.
"Their approach is intriguing and has great potential, although it requires a lot of data," added Hamer, who was not involved in the study.
That means the findings are not likely to help much in poor countries in Africa, where yellow fever often strikes, because they do not have the infrastructure necessary to create such a surveillance system or alert network, Hamer said.
The best tool against yellow fever is the vaccine, which has been around since 1938.
The Brazilian government launched a massive campaign to vaccinate millions of people at the beginning of this year, primarily in the regions of Sao Paulo, Rio and Bahia.
But there were not enough doses, sparking shortages in the country of 208 million people.
Researchers say priority needs to be given to those at high risk, including those nearest to rural areas and forests, such as the middle aged men at the center of the outbreak in southeast Brazil.
"We need this information to control future outbreaks -- to vaccinate the right people, in the right place, at the right time," said co-author Oliver Pybus, professor of evolution and infectious disease at Oxford University.
Vigilance is needed, even though the virus did not enter a cycle of urban transmission, as feared.
"We're learning that so many of our most worrisome infectious diseases are emerging in humans due to deforestation and closer proximity of humans to animals," said Peter Hotez, dean of the National School of Tropical Medicine at Baylor College of Medicine in Houston.
"For example, Ebola in Sub-Saharan Africa now appears to have originated from bats, as did SARS and MERS coronaviruses in China and Saudi Arabia, respectively, and Nipah virus as recently described in India."