CAIRO — The convoy of four sport utility vehicles full of Mexican tourists was about three hours southwest of Cairo on a typical adventure trip through the White Desert, an otherworldly landscape of monumental chalk-rock formations. Around midday on Sunday, a diabetic passenger complained that she needed to eat.

So, with the blessing of their police escort, and the apparent added security of an Apache military helicopter buzzing on the horizon, the group pulled off for a picnic, according to witnesses and others briefed on the trip.

Then the helicopter opened fire, killing at least a dozen people — including at least two Mexicans — while wounding a tourist police officer and at least nine others.

Some were gunned down as they tried to flee toward the top of a nearby sand dune, said Essam Monem, a resident of the area who arrived that night and saw the bodies sprawled in the sand.

The helicopter crew had mistaken the lunching tourists for a camp of Islamist militants operating in the area, the Interior Ministry said in a statement Monday. The error killed more tourists than any terrorist attack in recent years, raising questions about both the competence of Egypt’s security forces and the prevalence of the militants they were hunting.

The deadly mistake is the latest setback facing President Abdel Fattah el-Sisi’s efforts to restore stability, two years after the military takeover that brought him to power.

The disaster threatens to undermine a nascent recovery in the vital tourist industry, points to a failure to re-establish public security that has driven away investors, and embarrasses Mr. Sisi just days after he sought a new beginning by firing his prime minister and cabinet.

“What we saw was not just the lack of training of the military forces, but also their desperation,” said Mokhtar Awad, a researcher at the Center for American Progress, noting that Islamic State militants in the area had also released photographs on Sunday that appeared to show they had beaten an army unit in battle earlier the same day.

“It tells you how chaotic the situation is,” he said, “if they feel so desperate to put an end to this that they end up taking out what we gather is the first thing they see.”