Egyptian security forces have killed 12 Mexicans and Egyptians and injured 10 "by accident" after mistaking a tourist convoy for militants they were chasing in the country's western desert.

At least two Mexicans were killed, Mexico's foreign ministry said in a statement.

A joint force from the Egyptian police and military was chasing militants in the country's vast western desert, which borders Libya, when it inadvertently opened fire on the convoy.

The convoy was made up of four four-wheel drive vehicles, the Egyptian interior ministry said, and there will be an investigation into how and why the tourists entered an off-limits area.

Mexican President Enrique Pena Nieto condemned the attack on his Twitter account, describing it as a tragic incident and demanding a full investigation.

"Mexico condemns these deeds against our citizens and has demanded an exhaustive investigation of what has occurred," he tweeted.

A spokesman for Egypt's tourism ministry said the convoy was at an off-limits site and was using unlicensed cars.

Mexican ambassador Jorge Alvarez met with five Mexicans who were in stable condition in hospital, Mexico's foreign ministry said.

The Mexican ministry said an "undetermined" number of its country's nationals had been attacked and that it was in the process of identifying the two who had been killed.

Egypt is battling an insurgency that gained pace after the military ousted Islamist President Mohamed Mursi of the Muslim Brotherhood in mid-2013 after mass protests against his rule.

The insurgency, mounted by Islamic State's Egyptian affiliate, has killed hundreds of soldiers and police and has started to attack Western targets.

On Sunday Islamic State (IS) released a statement carried by its supporters on Twitter saying it had repelled an attack by the Egyptian military in the western desert.

While the insurgency has been largely based in the Sinai Peninsula, attacks have taken place in Cairo and other cities. In August, an Egyptian military aircraft crashed in the western desert near the Libyan border while on a mission against Islamist militants, killing four people.

Security officials say militants operating from Libya to the west of Egypt have been trying to forge ties with Islamists in the Sinai on the east side of the country.

Egyptian jets bombed IS targets in Libya in February, a day after the group there released a video showing the beheading of 21 Egyptian Christians, drawing Cairo directly into factional conflict across its border.