Iran is secretly forging ties with al-Qaida elements and Sunni Arab militias in Iraq in preparation for a summer showdown with coalition forces intended to tip a wavering US Congress into voting for full military withdrawal, US officials say.

"Iran is fighting a proxy war in Iraq and it's a very dangerous course for them to be following. They are already committing daily acts of war against US and British forces," a senior US official in Baghdad warned. "They [Iran] are behind a lot of high-profile attacks meant to undermine US will and British will, such as the rocket attacks on Basra palace and the Green Zone [in Baghdad]. The attacks are directed by the Revolutionary Guard who are connected right to the top [of the Iranian government]."

The official said US commanders were bracing for a nationwide, Iranian-orchestrated summer offensive, linking al-Qaida and Sunni insurgents to Tehran's Shia militia allies, that Iran hoped would trigger a political mutiny in Washington and a US retreat. "We expect that al-Qaida and Iran will both attempt to increase the propaganda and increase the violence prior to Petraeus's report in September [when the US commander General David Petraeus will report to Congress on President George Bush's controversial, six-month security "surge" of 30,000 troop reinforcements]," the official said.

"Certainly it [the violence] is going to pick up from their side. There is significant latent capability in Iraq, especially Iranian-sponsored capability. They can turn it up whenever they want. You can see that from the pre-positioning that's been going on and the huge stockpiles of Iranian weapons that we've turned up in the last couple of months. The relationships between Iran and groups like al-Qaida are very fluid," the official said.

"It often comes down to individuals, and people constantly move around. For instance, the Sunni Arab so-called resistance groups use Salafi jihadist ideology for their own purposes. But the whole Iran- al-Qaida linkup is very sinister."

Iran has maintained close links to Iraq's Shia political parties and militias but has previously eschewed collaboration with al-Qaida and Sunni insurgents.

US officials now say they have firm evidence that Tehran has switched tack as it senses a chance of victory in Iraq. In a parallel development, they say they also have proof that Iran has reversed its previous policy in Afghanistan and is now supporting and supplying the Taliban's campaign against US, British and other Nato forces.

Tehran's strategy to discredit the US surge and foment a decisive congressional revolt against Mr Bush is national in scope and not confined to the Shia south, its traditional sphere of influence, the senior official in Baghdad said. It included stepped-up coordination with Shia militias such as Moqtada al-Sadr's Jaish al-Mahdi as well as Syrian-backed Sunni Arab groups and al-Qaida in Mesopotamia, he added. Iran was also expanding contacts across the board with paramilitary forces and political groups, including Kurdish parties such as the PUK, a US ally.

"Their strategy takes into account all these various parties. Iran is playing all these different factions to maximise its future control and maximise US and British difficulties. Their co-conspirator is Syria which is allowing the takfirists [fundamentalist Salafi jihadis] to come across the border," the official said.

Any US decision to retaliate against Iran on its own territory could be taken only at the highest political level in Washington, the official said. But he indicated that American patience was wearing thin.

Warning that the US was "absolutely determined" to hit back hard wherever it was challenged by Iranian proxies or agents inside Iraq, he cited the case of five alleged members of the Revolutionary Guard's al-Quds force detained in Irbil in January. Despite strenuous protests from Tehran, which claims the men are diplomats, they have still not been released.

"Tehran is behaving like a racecourse gambler. They're betting on all the horses in the race, even on people they fundamentally don't trust," a senior administration official in Washington said. "They don't know what the outcome will be in Iraq. So they're hedging their bets."

The administration official also claimed that notwithstanding recent US and British overtures, Syria was still collaborating closely with Iran's strategy in Iraq.

"80% to 90%" of the foreign jihadis entering Iraq were doing so from Syrian territory, he said.

Despite recent diplomatic contacts, and an agreement to hold bilateral talks at ambassadorial level in Baghdad next week, US officials say there has been no let-up in hostile Iranian activities, including continuing support for violence, weapons smuggling and training.

"Iran is perpetuating the cycle of sectarian violence through support for extra-judicial killing and murder cells. They bring Iraqi militia members and insurgent groups into Iran for training and then help infiltrate them back into the country. We have plenty of evidence from a variety of sources. There's no argument about that. That's just a fact," the senior official in Baghdad said.

In trying to force an American retreat, Iran's hardline leadership also hoped to bring about a humiliating political and diplomatic defeat for the US that would reduce Washington's regional influence while increasing Tehran's own.

But if Iran succeeded in "prematurely" driving US and British forces out of Iraq, the likely result would be a "colossal humanitarian disaster" and possible regional war drawing in the Sunni Arab Gulf states, Syria and Turkey, he said.

Despite such concerns, or because of them, the US welcomed the chance to talk to Iran, the senior administration official said. "Our agenda starts with force protection in Iraq," he said. But there were many other Iraq-related issues to be discussed. Recent pressure had shown that Iran's behaviour could be modified, the official claimed: "Last winter they were literally getting away with murder."

But tougher action by security forces in Iraq against Iranian agents and networks, the dispatch of an additional aircraft carrier group to the Gulf and UN security council resolutions imposing sanctions had given Tehran pause, he said.

Washington analysts and commentators predict that Gen Petraeus's report to the White House and Congress in early September will be a pivotal moment in the history of the four-and-a-half-year war - and a decision to begin a troop drawdown or continue with the surge policy will hinge on the outcome. Most Democrats and many Republicans in Congress believe Iraq is in the grip of a civil war and that there is little that a continuing military presence can achieve. "Political will has already failed. It's over," a former Bush administration official said.

A senior adviser to Gen Petraeus reported this month that the surge had reduced violence, especially sectarian killings, in the Baghdad area and Sunni-dominated Anbar province. But the adviser admitted that much of the trouble had merely moved elsewhere, "resulting in spikes of activity in Diyala [to the north] and some areas to the south of the capital". "Overall violence is at about the same level [as when the surge began in February]."

Iranian officials flatly deny US and British allegations of involvement in internal violence in Iraq or in attacks on coalition forces. Interviewed in Tehran recently, Mohammad Reza Bagheri, deputy foreign minister for Arab affairs with primary responsibility for Iran's policy in Iraq, said: "We believe it would be to the benefit of both the occupiers and the Iraqi people that they [the coalition forces] withdraw immediately."