Iraq is helping to shore up the besieged regime of Syrian President Bashar al-Assad by allowing Iranian arms and fighters to cross into Syria from Iraq, Secretary of State John F. Kerry charged Sunday.

During an unannounced trip to Baghdad, Kerry lobbied Iraqi Prime Minister Nouri al-Maliki for greater scrutiny of flights that cross Iraq. He appeared to make little headway with Maliki, a Shiite with long-standing ties to Iran and little inclination to do U.S. bidding 10 years after the American invasion that toppled dictator Saddam Hussein.

Maliki is a prickly leader whose relations with U.S. officials have grown more strained since the departure of American forces and the re-emergence of widespread sectarian violence in Iraq. Maliki’s consolidation of power worries his U.S. backers. His dealings with Shiite Iran worry them more.

“Iraq’s success will take enormous cooperation,” Kerry said. “It’ll take dialogue, and it’ll take courage. It’ll require the resolve to defend the sovereignty of the country and its airspace. . . .

“We all want to see Iraq succeed. There’s such an enormous investment of our treasure, our people and our money in this initiative.”

The Obama administration has been unable to persuade Iraq to block overflights from Iran or even to perform regular inspections.

“We had a very spirited discussion,” Kerry said after the meeting with Maliki, “and I made it very clear to the prime minister that the overflights from Iran are, in fact, helping to sustain President Assad and his regime.”

Kerry began the session with Maliki by joking that he had been assured that the Iraqi leader would “do everything that I say.” Maliki had a good-natured reply: “We won’t do it,” he said through an interpreter. Both men smiled.

Iraq says Iranian flights over its territory carry only humanitarian supplies for the civil war in next-door Syria, and the only two known inspections of Iranian aircraft found just those supplies.

The United States says the sheer volume of flights and overland vehicle traffic to Syria through Iraq points to regular arms shipments. A senior U.S. official traveling with Kerry said there are flights nearly every day. The official would not say how the United States is certain that the planes are carrying weapons for Assad, an Iranian ally, but repeatedly asserted that is the case.

“We know” the contents, said the official, who spoke on the condition of anonymity to preview Kerry’s argument to Maliki.

Iraq is not part of a U.S.- and European-led group of nations backing the Syrian rebels in their effort to oust Assad. The leader of the main U.S.-backed Syrian opposition group resigned Sunday amid infighting. Kerry said he was sorry, but not surprised, to see Mouaz al-Khatib leave.

“It’s almost inevitable, in the transition of a group such as the opposition, for these kinds of changes to take place as it evolves,” Kerry said.

Addressing the prospects for talks between Israel and the Palestinians after President Obama’s recent Middle East visit, Kerry was cautious.

“All of us have learned in the course of the last years, through many presidents and many secretaries of state, there has been no more intractable problem,” he said. “And so, expressing optimism when you don’t even have negotiations would be foolhardy. What I have is hope.”

In Iraq, Kerry also pressed Maliki to reconsider a decision to postpone local elections in two Sunni-majority provinces and to share power more equally with Sunnis and Kurds. The secretary also invoked Iraq’s first free election, in 2005, to urge Maliki to revisit the issue.

“No country knows more about voting under difficult circumstances than Iraq,” Kerry said at a news conference at the U.S. Embassy.

Iraq remains badly divided along sectarian lines, with near-daily killings and terrorist attacks attributed to sectarian rivalries. The Shiite-led cabinet last week postponed the elections, scheduled for April 20, for up to six months in Anbar and Nineveh provinces, citing threats to electoral workers.

“It would be disingenuous not to come here and say that there is a great deal of work yet to do. The United States is clear-eyed about the challenges that are still presented here in Iraq,” Kerry said.

Kerry’s visit comes at a low point for American influence. The Obama administration was unable to negotiate a long-term security agreement with the Maliki government, leading to the departure of all U.S. forces and most civilians by late 2011.

The mammoth U.S. Embassy in downtown Baghdad, the largest and most expensive in the world, is downsizing from more than 16,000 employees to about 5,000 this year. Only about 1,000 of those left will be diplomats.

The United States also is dismantling the vestiges of a police training program once envisioned as its signature contribution to postwar Iraq, in an acknowledgment of Iraqis’ lack of interest in a multibillion-dollar investment designed to bolster the country’s troubled judicial system.

Kerry’s trip is the first to Iraq by a U.S. secretary of state since Hillary Rodham Clinton traveled here in 2009, and it comes amid growing criticism from Iraqi officials, who say the United States has not done enough to build a strong postwar relationship with Baghdad.

American officials say that they are committed to building a stronger relationship with Iraq but that the country’s deadlocked politics, security concerns and endemic corruption have hindered U.S. investment.

Overall, Ambassador Stephen Beecroft said in a recent interview, the United States has made significant contributions to Iraq, the many missteps of the war notwithstanding.

“It’s a vastly different place,” Beecroft said, reflecting on the U.S. legacy in Iraq. “It basically took Iraq from a very limited society that had very limited options and opportunities for its people and opened those up to a democratic system that provides much more in the way of freedom and choices and opportunities.”

Many Iraqis have a dimmer view of the situation in their country, citing a stubborn insurgency, rising sectarian tension and a political crisis that has led Sunnis and Kurds to boycott Maliki’s Shiite-run government.

No Kurdish leaders came to Baghdad to meet Kerry.

Ernesto Londoño and Karen DeYoung contributed to this report.