BAGHDAD — Under a fierce summer sun, an Iraqi police unit marches forward, braced together under riot shields protecting them from a barrage of rocks and, moments later, kicks from a scrum of men before them. The Iraqis then shuffle through a line of smoke and flames, an illustration of their ability to manage an unruly public gathering without resorting to force.

The riot control exercises are part of an expanding police training program led by Italy’s Carabinieri, or gendarmerie police, which has stationed about 50 trainers in Iraq as part of the U.S.-led military coalition against the Islamic State. The goal is to ensure that Iraq’s military-style federal police and local police contribute to the Iraqi government’s battle against militants and, equally important, can keep the peace once cities are cleared of militants. Since the current program began in June 2015, Italian personnel have trained more than 3,000 Iraqi police. Almost 1,000 more are being trained this summer.

It’s not the first time Italy has dispatched Carabinieri, who have carved out a niche in training foreign police in places including Kosovo, Lebanon, Afghanistan, and now Iraq. From 2004 to 2006, Italians trained police in Nassiriya south of Baghdad. Then, in 2007, they set up a facility at “Camp Dublin,” attached to Baghdad’s airport, where they conducted training until the withdrawal of foreign forces in 2011.

The Carabinieri’s return to Camp Dublin last year is an illustration of European countries’ stake in the fight against the Islamic State, which has already struck the continent. It also highlights Europe’s often-overlooked role in the U.S.-led military effort in Iraq.

There’s a deja-vu nature to the Italian training effort, like that now being done elsewhere in Iraq by other Western nations. Foreign advisers are scrambling to shore up local forces that were trained at a cost of billions of dollars after the 2003 invasion, but then partially collapsed in 2014.

The United States and other nations, including Australia, France, and the Netherlands, are also training and advising other segments of Iraq’s security forces, including the conventional army and the elite Counterterrorism Service. While officials in Rome have sought to maintain a low profile for its mission, a reflection of public feelings at home, Italy is set this year to become the second largest troop contributor to Iraq after the United States, officials said. Italian Special Operations forces are advising elite police units, and the government is planning to place 500 soldiers to guard an Italian company conducting repairs to the Mosul dam.

This time around, the Italian trainers are concentrating on a number of key areas, including SWAT tactics, explosives and counterterrorism investigations.

The Carabinieri are also trying to foster the use of more sophisticated law enforcement techniques. Capt. Raffaello Imbalzano, one of the trainers, said that forensic process was a weakness for the Iraqi government, which typically relies instead on family links or human intelligence to identify suspects after a terrorism attack. Lt. Col. Neil Dario, who heads the training contingent at Camp Dublin, said law enforcement authorities have sometimes paid sources for information.

In one classroom, a female Carabineri trainer shows plainclothes investigators from the Iraqi Interior Ministry how to retrieve fingerprints off a plastic water bottle so that the students are better able to investigate the site of a suicide bombing, for instance.  The foreign personnel are also putting the investigators through surveillance drills.

Iraqi Interior Ministry investigators said they normally try to track down bombing suspects by exploiting SIM cards used in bombers’ mobile phones, or by using the engine or chassis number from vehicles employed in the attack.

In their renewed mission, the Carabinieri face some of the same issues that have posed an obstacle to American efforts to turn around Iraqi army units: attendance and r

etention problems, low literacy among the rank-and-file, and poor infrastructure at Iraqi training sites.

In another classroom at the Iraqi federal police academy, where the Carabinieri conduct their training, the Iraqi pupils’ desks are bare as trainers provide technical instructions on counter-explosive procedures. No one is taking notes, officers overseeing the training explained, because many of the enlisted personnel have limited literacy skills. They say the field drills are better.

The instructors here, as they do at similar sites across Iraq, must also deal with the same kind of supply and infrastructure problems that have hindered Iraqi forces in their campaign against the Islamic State. On one recent day, most of the trainees had been sent home because a nearby water pipe had been severed.

At the request of the Iraqi government, the Caribineri have also added crowd and riot control to the curriculum. Last month, the government used live fire and tear gas when protesters stormed the heavily fortified Green Zone. It was the latest in a series of demonstrations challenging Prime Minister Haider al-Abadi, who is facing pressure to deliver on promised reforms and demonstrate his authority leading a nation facing security and fiscal crisis and ongoing sectarian strife.

Those trained in anti-riot tactics will then train other police.

Col. Hussein Sanih Zabun Ali, commander of Iraq’s federal police academy, said the specialized training was important as law enforcement faces the likelihood of continued protests. “We need these to be peaceful protests, so we aren’t training police how to respond violently,” he said.

Iraq’s federal police force is a paramilitary-style force with artillery, special forces and officers pulled from the Iraqi army. Speaking in an interview, the colonel said that the federal police, who often fight alongside militia forces who have played a significant role in recent battles, had taken heavy casualties in combat against the Islamic State. “Federal police is taking place in all the battles in Iraq,” he said.

Several battalions trained by the Caribinieri over the last year have taken part in operations to reclaim the western city of Fallujah from the Islamic State, Italian officials at the school said.

The Carabinieri also train police in code of conduct and human rights. Whether local police can maintain the support of residents in areas where the Islamic State has been defeated will be crucial in ensuring the group doesn’t make a comeback. Since 2014, there have been some allegations that the federal police have taken part in battlefield abuses.

One Interior Ministry investigator receiving Italian instruction was eager to point out that Iraqi police, like the rest of the country’s security forces, were at the forefront of the battle against a group that threatens a broad list of nations.

“We are on the front of the fighting; we are doing this on behalf of the world,” the officer said.