The continuing violence in Iraq over the last four months reflects, in part, insurgents' response to coalition military forces going on the offense, the top U.S. commander there said Sunday.

Gen. David Petraeus described an ebb-and-flow of sectarian murders in Baghdad and said there has been a "stunning reversal" in the Anbar province, a former al-Qaida stronghold west of the city where tribes have begun to help fight the terror organization.

He acknowledged, however, "real concerns" in some neighborhoods in and around Baghdad where Sunni and Shiites continue to battle.

"The fact is that as we go on the offensive, the enemy is going to respond. That is what has happened," Petraeus said in an interview from Baghdad. "Certainly it is a mix. And that is what I have tried to convey in my assessments — that we are ahead in some areas and we need to do some serious work in others."

In a required quarterly report to Congress on security, political and economic developments in Iraq, the Pentagon last week concluded that casualties among troops and civilians have edged higher despite the U.S.-led security push in Baghdad.

The report, covering the February-May period, also raised questions about Prime Minister Nouri al-Maliki's ability to fulfill a pledge made in January to prohibit political interference in security operations and to allow no safe havens for sectarian militias.

Overall, however, the report said it was too soon to judge whether the security crackdown was working.

Similarly, the U.S. ambassador in Baghdad, Ryan Crocker, described the situation in Iraq as "a mixed picture, but certainly not a hopeless one." He said there are frustrations, but also signs of progress, and cautioned about the ramifications of a precipitous withdrawal of forces.

"In terms of the political agenda, clearly we are frustrated with the slow progress that is being made on the legislative benchmarks," Crocker said Sunday. "The Iraqis are frustrated, too. They are working hard on these things. The fact is they are difficult to do, difficult in and of themselves ... and difficult in the current security climate."

He said the Iraqis are "very close" to agreement on a plan for managing the country's oil production and share resources.

"It's a mixed picture. There is some progress, but there's a lot of frustration and it's a frustration the Iraqis share."

He said the recent U.S. buildup of forces is just now complete and is showing signs of progress in establishing security, particularly in Anbar province.

To charges that the plan has produced a "whack a mole" result in which insurgents are routed in one location, only to pop up in another, Crocker said, "What we are now positioned to do ... is whack a whole lot of moles simultaneously."

The Pentagon's most recent report, the eighth in a series, said that while violence fell in the capital and in Anbar province, it increased in other areas, particularly in the outlying areas of Baghdad province and in Diyala province northeast of Baghdad and in the northern province of Nineva.

The security operation was launched Feb. 14 and is still unfolding as the last of an additional 28,000 or so U.S. forces are getting into position in and around the Iraqi capital. The Pentagon is required by Congress to provide its initial assessment of the operation in July.

Petraeus and Crocker will submit another report in September that could address how long troops, and how many soldiers, will need to remain in Iraq to help stabilize security. Both men declined to comment on what the report will conclude.

"It will be a snapshot, obviously, but that film can't be developed until we're there in September," Crocker said.

Petraeus cautioned that final resolution in Iraq could take time.

"Just about everybody out there recognizes that a situation like this, with the many, many challenges that Iraq is contending with is not one that's going to be resolved in a year or even 2 years. In fact, typically, even historically, counterinsurgency operations have gone at least nine-to-ten years," Petraeus said. "The question is, of course, at what level."

He added: "There is some possibility of some form of long-terms security arrangement over time, and I think in general, that's a fairly realistic assessment, assuming that the Iraqi government, in fact, does want that to continue."

In their September report, Crocker said he and Petraeus owe it to civilian leadership "at both ends of Pennsylvania Avenue" to explain what the consequences might be if the U.S. mounts a quick withdrawal.

He said Iran and Syria are playing "distinctly unhelpful roles" in Iraq and "we've got to consider what may happen" if the U.S. pulls out before Iraq is able to stand on its own.

Petraeus spoke on "FOX News Sunday," and Crocker also was interviewed from Baghdad on NBC's "Meet the Press."