CAIRO (Reuters) -Egypt formed a crisis unit on Thursday to investigate the deaths of Egyptians taking part in the annual Muslim pilgrimage to Mecca during extreme heat, after medical and security sources said at least 530 Egyptians had died and 31 were missing.

In recent days hundreds of people from different countries have died in punishing conditions for the haj pilgrimage in the Saudi Arabian city, where temperatures have at times exceeded 51 degrees Celsius (124 Fahrenheit).

The medical source, who was with the official Egyptian haj delegation, said the majority of those who died were not formally registered for the event with the authorities, which meant they could not access tents.

In a statement announcing the formation of the crisis unit on the orders of President Abdel Fattah al-Sisi, Egypt's cabinet said 28 deaths had been confirmed from a group of 50,752 officially registered Egyptian pilgrims.

It gave no toll for unregistered pilgrims, saying Egypt was seeking an accurate inventory of the dead and missing and was coordinating with Saudi counterparts to arrange for the transfer of bodies.

Companies that had facilitated travel for unregistered pilgrims would be investigated and penalised, the cabinet added.

A Reuters witness said that during the pilgrimage thousands of pilgrims had lain on the streets, exposed to the sun, on the climb to Mount Arafat, one of the integral rituals of the journey.

The bodies of dead pilgrims were later covered with Ihram cloth - a simple garb worn by pilgrims - until medical vehicles arrived, the witness said.

The fifth pillar of Islam, the haj is mandatory once in a lifetime for every able-bodied Muslim who can afford it and is the most significant manifestation of Islamic faith and unity. This year's event, which began last Friday, is expected to draw nearly 2 million pilgrims.

Climate scientists have said rising temperatures pose a growing threat to the event, although heat-related deaths along the haj are not new, and have been recorded back to the 1400s.

(Reporting by Ahmed Mohamed HassanWriting by Farah SaafanEditing by Aidan Lewis, Frances Kerry and Barbara Lewis)