DUBAI, United Arab Emirates (AP) — Saudi Arabia on Thursday banned foreign pilgrims from entering the kingdom to visit Islam’s holiest sites over the new coronavirus, potentially disrupting the plans of millions of faithful ahead of the Muslim fasting month of Ramadan and as the annual hajj pilgrimage looms.

The decision showed the growing worry across the Mideast about the virus as Iran confirmed that infected cases in the country spiked by over 100, to 254 now. A total of 26 people have died so far, it said. That pushes the region’s overall cases to above 350. Iran’s death toll is highest outside of China, where the outbreak began.

Saudi Arabia’s barring of pilgrims from Mecca, home to the cube-shaped Kaaba that the world’s 1.8 billion Muslims pray toward five times a day, and also the holy city of Medina, appeared unprecedented in modern history. The kingdom’s Al Saud ruling family stakes their legitimacy in overseeing and protecting the sites. Authorities also suspended entry to travelers from nations affected by the new virus who hold tourist visas for the kingdom.

It appeared Saudi officials worried about the risk of pilgrims spreading the virus as they had in Iran. The virus’ epicenter in the Islamic Republic is the holy Shiite city of Qom, where the faithful in reverence reach out to kiss and touch a famous shrine. That shrine and others have remained open, despite Iran’s civilian government calling for them to be closed.

There have been no confirmed cases of the new coronavirus in Saudi Arabia amid the outbreak.

“Saudi Arabia renews its support for all international measures to limit the spread of this virus, and urges its citizens to exercise caution before traveling to countries experiencing coronavirus outbreaks,” the Saudi Foreign Ministry said in a statement announcing the decision. “We ask God Almighty to spare all humanity from all harm.”

News of the cancellation shocked the Muslim world, as many save their entire lives for a chance to see the Kaaba and walk along the path of the Prophet Muhammad and visit his tomb in Medina.

Hundreds of faithful deplaned in Pakistan as the ban came into effect, while Indonesia and Turkey had to turn away thousands of pilgrims set to fly. Authorities at Cairo’s international airport said the Saudi decision created “intense confusion” and “extreme anger” among thousands of passengers waiting for flights. Security officials needed to call in reinforcements to control the crowd as news of the ban broke, said the officials, who spoke on condition of anonymity as they weren’t allowed to speak to reporters.

Disease outbreaks always have been a concern surrounding the hajj, which is required of all able-bodied Muslims once in their life, especially as pilgrims come from all over the world. The earliest recorded outbreak came in 632 as pilgrims fought off malaria. A cholera outbreak in 1821 killed an estimated 20,000 pilgrims. Another cholera outbreak in 1865 killed 15,000 pilgrims and then spread worldwide.

More recently, Saudi Arabia faced the danger from another coronavirus, one that causes the Middle East respiratory syndrome, or MERS, which jumped from ill camels to humans. The kingdom increased its public health measures during the hajj in 2012 and 2013 and urged the ill and the elderly not to take part in the pilgrimage.

WATCH: Trump moves to reassure public on virus response, appointing Pence to lead it

Since September 2012, there have been nearly 2,500 cases of MERS reported, with 858 deaths attributed to the virus, according to the World Health Organization. However, the hajj itself saw no MERS outbreak. Saudi officials also instituted bans on pilgrims coming from countries affected by the Ebola virus in recent years as well.

Since the new coronavirus emerged in December in central China, it has sickened 82,000 people globally, with more than 2,700 deaths. The illness it causes was named COVID-19, a reference to its origin late last year.

While millions attend the hajj, which is this year set for late July into early August, millions more come during the rest of the year to the holy sites in the kingdom. Those other pilgrimages are referred to as the umrah, which drew 7.5 million people in 2019 alone. One of the biggest times for the umrah is the Muslim holy fasting month of Ramadan, which is set to begin at the end of April.

Those pilgrims spend upward of 10 days at holy sites, mingling in tight quarters. Of those coming, many are older, have pre-existing chronic diseases and come from countries “with suboptimal disease surveillance,” according to a letter Thursday to The Lancet medical journal.

“Respiratory infections are the most common illness among pilgrims … and the lack of social distancing among pilgrims as they engage in religious rituals amplifies their risk of acquiring and transmitting respiratory diseases,” the letter read.

The letter added: “We do not need to wait for the first case to emerge in Saudi Arabia’s holy sites. The time for preparedness is now.”

Dr. Ziad A Memish, a Saudi professor who studies infectious diseases and co-signed the letter, said he welcomed the kingdom’s decision.

“This is a very tough decision,” he told The Associated Press. “But with the rapid spread of COVID-19 and a lack of good diagnostics, preventative vaccines and therapeutics, this is the best decision that could be taken at such difficult times.”

Kristian Ulrichsen, a research fellow at the James A. Baker III Institute for Public Policy at Rice University, called the Saudi decision “unprecedented.”

“Given the worldwide spread of the virus and the global nature of the umrah, it makes sense from a public health and safety point of view,” said “Especially since the Iranian example illustrates how a religious crossroads can so quickly amplify the spread and reach of the virus.”

By leaving the suspension of travel to the holy sites open-ended, Saudi Arabia has opened the possibility of this year’s hajj potentially being disrupted as well.

The hardest-hit nation in the Mideast is Iran, where Health Ministry spokesman Kianoush Jahanpour on Thursday reported 26 deaths out of 245 confirmed cases of the illness. Experts are concerned Iran may be underreporting cases and deaths, given the illness’ rapid spread from Iran across the Persian Gulf.

Jahanpour seemed to address that, saying new labs in Iran were conducting tests and the number of confirmed cases could continue to spike in coming days. Thursday’s number represented a jump in over 100 new cases from the previous day.

Supreme Leader Ayatollah Ali Khamenei on Thursday praised medical staffers, calling their work “very invaluable.” But the virus has struck the official in charge of Iran’s response to the outbreak, as well as a reformist lawmaker. On Thursday, a hard-line cleric from Qom who also serves in parliament posted a video online acknowledging he had been infected.

“Yes, my corona test is positive, too and I am in quarantine,” Mojtaba Zonnouri said in the video. “God willing, our nation will overcome in fight against corona.”

Associated Press writers Nasser Karimi in Tehran, Iran; Munir Ahmed in Islamabad; Isabel DeBre in Cairo; Niniek Karmini in Jakarta, Indonesia; Andrew Wilks in Ankara, Turkey, and Qassim Abdul-Zahra in Baghdad contributed to this report.