Iraq's foreign minister said Wednesday his government and the U.S. have almost finished negotiating a new security pact that could give Iraqis a role in planning and executing joint military operations.

Both sides hope to wrap up the talks this month in time for Iraq's factious parliament to approve the deal to keep U.S. troops here after the U.N. mandate expires at the end of the year.

Less than three weeks ago, Iraqi Prime Minister Nouri al-Maliki said negotiations were deadlocked. But Foreign Minister Hoshyar Zebari said Wednesday after his recent visit to Washington that the U.S. "showed recently a great deal of flexibility on many of the thorny issues."

Those issues include the authority to carry out military operations in Iraq and arrest the country's citizens, legal immunity for private contractors and U.S. soldiers and control of Iraqi air space.

Many Iraqi lawmakers have complained that U.S. demands would infringe on Iraqi sovereignty, but few want to see U.S. forces leave before Iraq's army and police can handle security.

Zebari told reporters Wednesday that U.S. forces could not stay in Iraq without a legal agreement. If the two countries fail to finalize a new security deal, the foreign minister said Iraq would either have to seek an extension of the U.N. mandate or accept a temporary agreement with the U.S. more limited in scope, neither of which is attractive to most Iraqi lawmakers.

But Zebari said negotiations were moving in the right direction, with the U.S. agreeing that the authority to carry out joint military operations in Iraq "should be based on the principle of partnership and cooperation or a higher joint committee."

He also said Washington agreed that Iraq's courts should have control over the detention of Iraqi citizens — a major issue here given the thousands of Iraqis currently held by U.S. forces.

During an appearance Tuesday before parliament, Zebari said the U.S. has agreed to end the legal immunity enjoyed by U.S. and other foreign security contractors in Iraq.

He also said the U.S. was prepared to give up control of Iraqi air space if the Iraqis guarantee that they could protect the country's skies with their limited air force.

U.S. officials have declined to discuss details of the negotiations until the talks are completed. Once the deal is finalized, it must be approved by the Iraqi parliament.

The Shiite-led Iraqi government is negotiating the agreement at a time when it feels emboldened by several crackdowns against Sunni extremists and Shiite militias in several areas of the country.

On Wednesday, Iraqi security forces arrested three locally prominent supporters of radical Shiite cleric Muqtada al-Sadr in the southern city of Amarah, according to police who spoke on condition of anonymity because they were not authorized to talk to the media.

All three are members of the provincial council in Maysan, where Amarah is the capital. Police said the three were suspected of supporting Shiite militias.

Iraqi forces also arrested 30 guards employed by Maysan Gov. Adel Mhodir, also an al-Sadr supporter. Police said the guards were believed to be linked to militias.

A spokesman for al-Sadr, Sheik Salah al-Obaidi, criticized the arrests of the council members, saying the Iraqi government was targeting the cleric's followers without cause in violation of agreements reached with the national leadership before the Amarah operation.

Sadrist officials have complained for months that rival Shiite parties in the government were using security operations as a pretext to weaken al-Sadr's political movement ahead of provincial elections expected in the fall.

The U.N. special envoy to Iraq warned Tuesday that those elections could not be held on time because parliament hasn't passed necessary legislation. But al-Maliki insisted Wednesday that the elections would take place as planned.

The U.S. blames much of the violence in southern Iraq on "special groups" that it says have split off from al-Sadr and are being supported by the Iranians — a claim denied by Tehran. Iraqi security forces arrested five of these militants around central Iraq on Saturday, according to a U.S. statement.

Also Wednesday, a U.S. patrol was hit by a roadside bomb in the southeast area of Baghdad, wounding two soldiers and damaging one Humvee, the U.S. military said.

In eastern Diyala province, a police report said U.S.-allied Sunnis killed two Sunni militants nine miles south of the provincial capital, Baqouba.