With the occupation of Iraq due to end in three weeks, the Bush administration fears that Iran will move in as a major player after months of quietly building networks among Iraqi politicians and religious circles, according to U.S. officials in Washington and Baghdad.

For months, U.S. officials have watched warily as Iran built up its influence, deploying hundreds of personnel and channeling millions of dollars to secure ties that were impossible during Saddam Hussein's rule. The Bush administration believes Tehran's goal is to use deepening ties with Shiite and Kurdish leaders to quickly replace the United States as the country with the most widespread and enduring influence in Iraq.

"Iran is using all instruments available to interfere and be a very active player in Iraq," a senior U.S. intelligence official said. "Within the Shiite orbit, there's a large menu of actors, and Tehran is placing bets on enough of them to ensure it ends up with ties to a winner."

With Iraq's political spectrum still taking shape, Iran has covered most major options for the next phase of the transition that begins June 30 by providing various types of assistance to mainstream figures such as Grand Ayatollah Ali Sistani as well as radicals such as Moqtada Sadr; former U.S. favorite Ahmed Chalabi; and long-standing ally the Supreme Council for the Islamic Revolution in Iraq, U.S. sources said.

Tehran is also cultivating ties or providing material assistance to tribes, militias, interest groups, local notables, political parties -- often secular rather than religious -- to enhance its influence, U.S. officials said. "Anyone who provides Iran a chance" to pursue its interests said the intelligence official, who spoke on the condition of anonymity because of the sensitivity of the issue.

Iran has also become a rival to the United States in reconstruction, particularly in Shiite-dominated southern Iraq. The Bush administration has allocated $18.7 billion in aid, but only a tiny fraction -- in the low hundreds of millions -- has reached reconstruction projects or Iraqis, so that the two countries' assistance is in the same range, U.S. officials said.

Although U.S. funding has focused heavily on infrastructure, almost all of Iran's assistance has focused on more visible public services, such as health clinics, community centers and power generators that have boosted local allies. "They've tried to help Shia who have influence in the community get more influence," said a senior U.S. coalition official in Baghdad who also requested anonymity because of the sensitive subject.

After a quarter-century of hostile relations starting with the 1979 seizure of the U.S. Embassy in Tehran, the two countries find themselves in a race for influence that could deeply affect their respective interests throughout the Middle East and South Asia. In the short term, Washington believes that Tehran wants the United States to fail in Iraq for fear that the world's only superpower will gain even greater sway in shaping the region's future -- and feel empowered to launch military action against Iran next, U.S. officials said.

U.S. officials also said Iran is anxious that the U.S.-led multinational force withdraw soon. Since the terrorist attacks of Sept. 11, 2001, Iran has become almost surrounded by U.S. military deployments or facilities that the U.S. military has arrangements to use.

The State Department's 2003 terrorism report, issued in April, criticized Iran for meddling in Iraq and pursuing "a variety of policies in Iraq aimed at securing Tehran's perceived interests there, some of which ran counter to those of the coalition."

Yet in contrast to the U.S.-Iran struggle for influence in Lebanon two decades ago, when Iranian surrogates were held responsible for the deadliest attacks against U.S. embassies and a Marine headquarters, U.S. officials said Iran -- which is predominantly Shiite -- has not been linked to attacks on the U.S.-led coalition by predominantly Sunni extremist groups.

"We believe they do see advantages to having us be a little bloodied and to make clear that whatever happens will not be seen as a U.S. success in the region," the U.S. intelligence official said. "But the Iranians are very sensitive about getting exposed for doing anything open or violent against us."

Ironically, U.S. officials said the United States and Iran share the long-term goal of a stable, secular and unified Iraq where leaders are selected in democratic elections, because Iraq's Shiite majority would almost certainly give Shiite leaders a decisive edge. Iranian analysts agreed.

"If things deteriorate security-wise and the danger of ethnic tensions increases, it would create an unstable neighborhood, and the Americans might stay. Then the whole idea of Shiite influence and power will diminish, and chaos becomes a danger. And the last thing Iran wants is chaos, whether the U.S. stays or leaves," said M. Hadi Semati, a Tehran University political scientist now at the Carnegie Endowment for International Peace.

But Iran's involvement in Iraq is not a "monolithic conspiracy" and is often as divisive as its own political scene, further complicated by Iraqi ambitions, said a senior administration official familiar with transition plans. "There are a whole range of actors with a whole range of objectives -- and different emphasis in different parts of the country," he said. "And just like Iranians are trying to manipulate Iraqis, some Iraqis are trying to manipulate Iranians, too."

U.S. officials predict that Iran will have its own difficulties in Iraq, despite religious and cultural ties. Iraq is the most nationalist of the 22 Arab nations, and Iraqis oppose too much influence by any nation. During Hussein's rule, Iraq also fought a long war -- and suffered the highest casualties -- with Iran from 1980 to 1988, U.S. officials note. Although there is ethnic and religious overlap, Iraq's dominant ethnic group is Arab, while Iran is mainly Persian -- long-standing rivals.

More important, the two countries -- and their clerics -- have widely diverse visions of their future, U.S. officials said.

"Iranians know Iraqis don't have much love for them -- and that most Iraqis, including Grand Ayatollah Sistani, don't believe in the idea of veliyat-e faqih," or a supreme religious leader who has veto power over all branches of government and personnel, the administration official said. Sistani, Iraq's leading cleric, is Iranian-born and maintains an office in Qom, Iran's holiest city.

But U.S. analysts also warn that Washington will have little luck in preventing a growing Iranian role in Iraq. "For the United States to assume that they can stop Iran from being influential in Iraq is silly. It's like worrying that the Vatican might have influence in Ireland," said Juan Cole, a University of Michigan specialist on Shiite Muslims.