BERLIN (Reuters) - Iran is talking to the Taliban but has a “very ambivalent” attitude towards al Qaeda, a third major foe of the United States, a top European security official said.

Tehran’s relations with the Taliban and al Qaeda are of key importance because of Washington’s concerns they could carry out damaging attacks on the United States and its allies in the Middle East and Afghanistan.

The United States would be particularly wary of any growing relationship between the three as Tehran is looking for support in case of a possible U.S. strike on its nuclear facilities, which Washington says are being used to develop a nuclear bomb.

“I certainly believe the Iranians are conducting talks with the Taliban,” August Hanning, Germany’s deputy interior minister and former head of its BND spy agency, told Reuters in an interview.

He noted that Iran has also acknowledged holding some senior al Qaeda figures for years, possibly under some form of house arrest, and said Tehran might seek to use them as a “bargaining chip” against the West.

Although talks are under way with Iran over a diplomatic solution concerning Tehran’s nuclear program, Washington has not ruled out military strikes on its atomic facilities. Iran says it wants nuclear energy to generate electricity.

Western security analysts assume Shi’ite Iran is already planning its response to a U.S. attack. Some believe it might set aside its differences with the Sunni Taliban and al Qaeda in a bid to maximize its “asymmetric capacity” to retaliate.

The United States has long accused Iran of backing insurgents in Iraq and security experts say Tehran’s response to any U.S. airstrikes on its nuclear installations would include stepping up support of anti-U.S. forces in Iraq, Hezbollah in Lebanon and Hamas in the Palestinian territories.

The response could also spread to Afghanistan and beyond.

Hanning said he could not confirm reports heard by Reuters from two separate diplomatic and intelligence sources that Iranian officials have held two three-way meetings in Iran since June with militants from al Qaeda and the Taliban.

One source said a June meeting in Mashhad, near the Afghan border, was called to discuss “coordination” on how to respond if Iran came under attack.

The source said participants included Saif al-Adel, a senior al Qaeda figure whom intelligence sources believe has been held in Iran along with other top militants who fled there from Afghanistan after the U.S. invasion in 2001.

Western intelligence officials say they cannot confirm the reports, although some see them as plausible.

Hanning said he believed the Iranians were smuggling weapons into Afghanistan, where some 3,000 German soldiers are deployed in NATO peacekeeping operations to help rebuild the country and fend off an increasingly tough Taliban insurgency.

“I believe that the Iranians have an influence on the situation in Afghanistan, above all in the border regions,” Hanning said.

He did not say how he knew that Iran was talking to the Taliban, the purist Islamist militia which has regrouped in Afghanistan since its rule there was broken by the U.S. invasion soon after the September 11 attacks of 2001.

Hanning doubted that the Iranians would give up clandestine nuclear procurement efforts, even in the face of a new round of U.N. or separate European Union sanctions.

“If I know the Iranians, they have already taken the appropriate preparatory measures” to circumvent a tightening of sanctions, he added.

“It will always be possible to get around such regulations. They can do it through front companies, third countries. In an open society it is ... not easy to prohibit.”