Updated

The Iraqi military will use a medieval tactic to keep control of Fallujah after recapturing it from the Islamic State group last month: It is digging a trench around the city.

The trench will have a single opening for residents to move in and out of the city, which is virtually empty since the offensive that defeated the IS militants, said Lt. Gen. Abdul-Wahab al-Saadi, deputy commander of the counterterrorism forces that led the successful campaign.

It will be about 7 miles (11 kilometers) long and "will protect the city's residents, who have lived through many tragedies, as well as security forces deployed there," al-Saadi said in an interview with The Associated Press at his Baghdad headquarters.

Cutting off all roads but one will allow authorities to monitor the movements of residents more closely.Fallujah has been a source of car bombs used against Baghdad, which is 40 miles (65 kilometers) to the east. Restricting traffic will be one way to try to stop any explosives-laden vehicles from leaving the city.

Besides the trench, more modern security measures also will be used.

Personal details of the estimated 85,000 residents who fled during the May-June battle to liberate the city will be stored electronically, and forgery-proof ID cards will be issued, according to Mayor Issa al-Issawi. Cars owned by residents also will be issued display badges containing electronic chips.

The trenches will be about 40 feet (12.5 meters) wide and 5 feet (1.5 meters) deep.

Work has begun on the first leg, running about 4 miles (6 kilometers) on the north and northwest side of the city, al-Issawi told the AP. Digging the second leg, which runs 3 miles (5 kilometers) along the south and southeast, will begin soon, he said.

The western edge of Fallujah abuts the Euphrates River, providing a natural barrier. On the east side is the heavily patrolled main highway to Baghdad, which will be the sole entrance to Fallujah.

The two trenches run through open desert areas used in the past by militants, said Maj. Gen. Saad Harbiyah, in charge of military operations in western Baghdad.

Iraqis have used various earthworks, walls and fortifications ever since the U.S.-led invasion that toppled Saddam Hussein in 2003. During the war, Saddam had trenches dug around Baghdad, filled them with oil and set them ablaze, using thick, black smoke to obscure the view for U.S. warplanes.

Since the war, Baghdad has become a city of concrete blast walls, erected to protect buildings but also to control the movement of people. During the 2006-07 sectarian violence between Shiites and Sunnis, entire neighborhoods were sealed off by blast walls to restrict and monitor access.

In January 2014, Fallujah became the first major Iraqi city to be captured by the Islamic State group. The extremists later swept through much of Anbar province, taking its capital, Ramadi, and much of the north, including Iraq's second-largest city of Mosul.

A U.S.-led coalition and Iranian-backed Shiite militia forces have helped the Iraqi army recapture territory from the Islamic State.

Security problems have plagued Iraq, especially in Fallujah. The city has been a center of Sunni opposition to Shiite-led governments in Baghdad, with Sunnis complaining of discrimination at the hands of the country's majority Shiites.

Fallujah residents have suffered under more than two years of rule by Sunni extremists of the Islamic State group. That suffering could be exacerbated if the security measures are seen by residents as too heavy-handed.

Security measures like the trench may make little difference in the long run if there is no reconciliation between Sunnis and a government many of them see as oppressive, illegitimate and a tool in the hands of Iraq's giant Shiite neighbor, Iran. Shiite hard-liners, in turn, see Sunnis as sympathetic to militants, many of whom view Shiites as infidels.

The Iraqi government also plans to dig a trench along the border between Anbar province, whereFallujah is located, and neighboring Karbala, home to one of Shiite Islam's holiest shrines. Work also has begun on walls and trenches around vulnerable parts of Baghdad's outer areas to guard against car bombs. In both cases, however, work has been slowed by lack of funds and corruption.

Fallujah faces its own internal differences as well. Some factions of its main tribal clans declared allegiance to IS, while others did not, prompting the extremists to kill prominent tribal members and blow up the homes of those who fled.

Iraqi authorities arrested about 21,000 Fallujah residents from among those who fled the city on suspicion of IS membership, according to al-Saadi. Following questioning, all were released except for about 2,000 who face further interrogation and possible prosecution, he added.

Tens of thousands of displaced residents will be allowed to return to Fallujah later this year, al-Saadi said.

"We must turn a new page with Fallujah. There is no other way for reconciliation," said al-Saadi, a veteran of the government's fight against militants in Anbar.

"We must punish those with blood on their hands, but not those who merely joined Daesh," he said, using the Arabic acronym for IS. "Revenge and mass trials will only breed more hatred and resentment."

Government spokesman Saad al-Hadithi echoed al-Saadi's view.

"We cannot judge people by their intentions. Only those who committed crimes will face justice," al-Hadithi told AP. The government intends to rely on the local police force and Sunni tribesmen to maintain security in Fallujah, he said.

But the chairman of Anbar's provincial council, Sabah al-Karhout, complained that "reconciliation efforts" were below what was needed and that much rides on how secure Fallujah residents feel when they return home.

"Marginalization must end so that calls for a federal system to disappear," he said, alluding to a growing sentiment among Iraq's Sunni Arabs for autonomy in their regions.