The order came after countries whose citizens performed this year's hajj reported more than 1,100 deaths, many attributed to the oven-like summer heat in Saudi Arabia.
An AFP tally on Friday, compiling official statements and reports from diplomats involved in the response, put the toll at 1,126, more than half of them from Egypt.
Arab diplomats told AFP earlier this week that Egyptians accounted for 658 deaths -- 630 of them unregistered pilgrims.
President Abdel Fattah El-Sisi had ordered that a "crisis cell" headed by Madbouly follow up on the deaths of Egyptian pilgrims.
"The prime minister has ordered the licences of these companies to be revoked, their managers to be referred to the public prosecutor and the imposition of a fine to benefit the families of the pilgrims who died because of them," the cabinet statement said.
It said the rise in the number of deaths of unregistered Egyptian pilgrims stemmed from some companies which "organised the hajj programmes using a personal visit visa, which prevents its holders from entering Mecca" via official channels.
50,000 Egyptians registered
The cabinet statement said more than 50,000 Egyptians joined the pilgrimage officially, and that there were "31 deaths as a result of chronic diseases".
It said the travel firms accused of arranging unauthorised hajj visits did not provide adequate services, "causing unregistered pilgrims to be exhausted as a result of high temperatures".
On Friday a senior Saudi official defended the Gulf kingdom's management of the pilgrimage.
Hajj permits are allocated to countries on a quota system and distributed to individuals by lottery.
Even for those who can obtain them, the steep costs spur many to attempt the hajj without a permit, though they risk arrest and deportation if caught.
The irregular route, which can save pilgrims thousands of dollars, has become increasingly popular since 2019 when Saudi Arabia introduced a general tourism visa making it easier to enter the Gulf kingdom.
The senior Saudi official said the government had confirmed 577 deaths for the two busiest days of hajj: Saturday, when pilgrims gathered for hours of prayers in the blazing sun on Mount Arafat, and Sunday, when they participated in the "stoning of the devil" ritual in Mina.
"This happened amid difficult weather conditions and a very harsh temperature," the official said, acknowledging that the 577 figure was partial and did not cover all of the hajj, which formally ended on Wednesday.
The hajj is one of the five pillars of Islam that all Muslims with the means must complete at least once in their lives.
Saudi officials had earlier said 1.8 million pilgrims took part this year, a similar number to last year, and that 1.6 million came from abroad.
The timing of the hajj is determined by the Islamic lunar calendar, shifting forward each year in the Gregorian calendar.
For the past several years the mainly outdoor rituals have fallen during the sweltering Saudi summer.