BAGHDAD - Iraqi soldiers, backed by U.S. helicopters, stormed an encampment of hundreds of insurgents hiding among date palm orchards in southern Iraq in an operation yesterday that set off fierce, daylong gun battles.

Iraqi security officials said the troops killed scores of insurgents while foiling a plot to annihilate the Shiite religious leadership in the holy city of Najaf. A U.S. helicopter crashed during the fighting, killing two soldiers.

The spokesman for Iraqi security forces in Najaf, Col. Ali Nomas Jerao, said that 250 suspected insurgents were killed in the fighting, which took place about eight miles northeast of Najaf, and that 40 people were detained. The U.S. military did not provide death tolls for Iraqi forces or insurgents.

Thousands of Shiite pilgrims from Iraq and neighboring countries are traveling this week in drum-beating caravans to the southern city of Karbala, 50 miles north of Najaf, in commemoration of the death of the prophet Muhammad's grandson in the seventh century. Iraqi authorities said they believed that the fighters, a diverse cadre of Sunni, Shiite, Afghan and other foreign gunmen, convened under cover of the pilgrims to set up a camp within striking distance of the Shiite religious leadership when attention was away from Najaf.

The fighters, who called themselves the Soldiers of the Sky, are driven by an apocalyptic vision of clearing the Earth of the depraved in preparation for the second coming of Muhammed al-Mahdi, a Shiite imam who disappeared in the ninth century, according to Ahmed Duaibel, a spokesman for the provincial government in Najaf. The governor of Najaf province, Assad Abu Gilel, said the group planned to attack pilgrims and shrines and to assassinate Shiite clerics at the peak of the religious holiday, called Ashura, which culminates tomorrow.

"Today's attack was designed to destroy all of Najaf, even the holy shrine of Imam Ali," Duaibel said, referring to one of the most revered Shiite shrines. If successful, such a provocative attack could surpass in significance the bombing at the Askariya shrine in Samarra in February, which drastically escalated sectarian killing in Iraq.

The fighting began overnight when a police checkpoint near Najaf came under fire, leading the Iraqi police to the farms in the Zargaa area where the fighters had dug trenches and stockpiled weapons, said Lt. Rahim al-Fetlawi, a police officer in Najaf. The police who responded found themselves outgunned by the estimated 350 to 400 insurgents entrenched there, said Col. Majid Rashid of the Iraqi army in Najaf. Reinforcements from the 8th Iraqi Army Division arrived, along with U.S. helicopters and ground troops. During the operation, a U.S. military helicopter based in Baghdad crashed, killing two soldiers, the military said. The military did not say whether the helicopter was shot down.

The prospect of insurgents lying in wait to attack Shiites illustrated the crisis between rival religious groups in Iraq, where extremists remain intent on undermining the religious and political order. The attack was the first large-scale battle since Iraqi forces assumed security control of the province last month.

Iraqi officials said the insurgent leader on yesterday was Ahmed Hassan al-Yamani, a Shiite from Diwaniyah province in southern Iraq.

Violence continued elsewhere in Iraq. In Baghdad, mortar shells crashed down on a girls' high school, killing at least five students and wounding 13 other people, including two female teachers, according to Brig. Gen. Saad Sultan of the Interior Ministry.

In addition to confirming the two Americans killed in the helicopter crash near Najaf, the U.S. command announced three combat deaths from Saturday - a Marine in Anbar province and two soldiers in the Baghdad area.