Iran’s expulsion of a senior al-Qaeda official appears to signal a crackdown on the terrorist group that has long been granted safe haven within its borders, U.S. officials say.

Iran’s ouster of Sulaiman Abu Ghaith, a former al-Qaeda spokesman and the son-in-law of Osama bin Laden, marked at least the third time in the past year that a prominent al-Qaeda figure has left the country after living for years in a limbo between houseguest and home detainee.

U.S. officials and terrorism experts say the tougher stance appears to reflect growing tensions between Iran’s Shiite clerics and the Sunni Muslim terrorist group, particularly over the civil war in Syria, where they are backing opposing sides.

At the same time, Western intelligence agencies see steps by Iran to preserve ties with al-Qaeda by allowing the group to use Iranian territory as a transit route to and from Afghanistan, U.S. officials and analysts say.

“We believe that Iran continues to allow al-Qaeda to operate a network that moves al-Qaeda money and fighters through Iran to support al-Qaeda activities in South Asia,” David S. Cohen, the Treasury Department’s undersecretary for terrorism and financial intelligence, said in an interview.

Highlighting the sometimes contradictory nature of the relationship, Cohen said the same transit networks send “funding and fighters to Syria,” where militant Islamists linked to al-Qaeda are battling pro-government forces supported by Iran. A group of fighters from the militant ­al-Nusra Front, which the State Department has said is linked to al-Qaeda in Iraq, is regarded as one of the most powerful anti-government forces in Syria.

Documents obtained from the bin Laden compound in Abbottabad, Pakistan, have shed further light on the relationship between al-Qaeda and Iran — a relationship both sides have preserved despite deep mistrust and sharp differences over ideology and tactics.

“It is a partnership of convenience, with some really rough edges,” said Bruce Riedel, a former CIA officer and counterterrorism adviser to the Obama administration.

The relationship for years included an unacknowledged policy of granting refuge to al-Qaeda members who fled to Iran after the defeat of the Taliban government in Afghanistan in late 2001. Iran allowed several top al-Qaeda officials and associates — including one of bin Laden’s wives and several of his children — to live in eastern Iran, freely at first, then under a loose form of house arrest.

U.S. officials say the restrictions were a response to Western pressure and a useful hedge against al-Qaeda misbehavior on Iranian soil. But a decade later, Iran appears to have grown weary of its “houseguests,” analysts say.

Iranian news media on Wednesday reported that security officials had recently arrested three members of the group. The semi-official FARS news agency quoted a senior army commander as saying the arrests occurred during border security operations. No details were given.

“We have arrested three al-Qaeda members in the country’s Western border regions in recent months and handed them over to the relevant authorities,” FARS quoted Kermanshah Calvary Division Gen. Ali Hajilou as saying.

Two senior al-Qaeda figures left Iran last year, although it was unclear whether they were asked to go or departed willingly. Abu Ghaith appears to have been given no choice, according to a narrative provided by U.S. officials and supported by postings on jihadist Internet sites. The former al-Qaeda spokesman and Sunni cleric was told this year to leave Iran for his native Kuwait.

Kuwaiti officials initially declined to accept him, so he flew to Turkey, where he was detained by police and then allowed to board a flight for Kuwait on Feb. 28. During a layover in Amman, Jordan, U.S. intelligence officers arrested Abu Ghaith, who now awaits trial in New York on a variety of terrorism-related charges.

The manner in which Abu Ghaith was expelled seemed calculated to result in his capture, suggesting that Iran was signaling a shift in the relationship, said Dan Byman, a counterterrorism expert at the Brookings Institution.

“It was a big move to send him not to Pakistan but in the opposite direction,” Byman said. “What we’re seeing is a slightly more confrontational al-Qaeda policy, suggesting that Iran is becoming more uncomfortable in hosting these guys.”

The wariness appears to be mutual, as seen in communications between al-Qaeda officials in the months before the killing of bin Laden in May 2011.

“The Iranians are not to be trusted,” bin Laden wrote in a May 2010 e-mail.

At the time, Iran had decided to grant al-Qaeda’s request to allow some of bin Laden’s family members to travel to Pakistan. Yet, bin Laden feared that the Iranians might spy on his relatives or lead them into a trap.

“It is possible that they may plant chips” in their belongings in order to eavesdrop, he wrote.

Iran appears to have sought to keep its al-Qaeda guests on a tight leash, alternately granting and withholding favors to maintain dependency, U.S. officials and analysts said.

The strategy helped ensure that al-Qaeda would not attack the Iranian government, and it allowed Iran to preserve the option of working with the group to carry out attacks against Western targets in the event Iran comes under attack, analysts said.

U.S. officials see no evidence of direct Iranian support of al-Qaeda terrorism in the United States or Western Europe. But Iran has a long history of supporting proxy groups that can strike against its enemies while insulating Iran from accountability, said Riedel, the former CIA officer.

“You can envision a situation in which the Iranians very carefully assisted al-Qaeda in an attack on the United States, as long as the attack is seen as al-Qaeda’s, with no Iranian fingerprints,” Riedel said. “There is much that Iran could do, simply by facilitating travel.”

Iran’s willingness to allow al-Qaeda to operate critical transit routes through its territory gives Iranian leaders a chit they can collect later, according to Riedel and other current and former U.S. officials.

Al-Qaeda’s Iranian pipeline for fighters and cash has been operating for years, using a network of “facilitators” who live along the route and provide a crucial link to sources of funding and manpower in the Arab gulf countries.

In the past 18 months, the Treasury Department has slapped sanctions on seven men accused of operating the pipeline, which routes volunteer fighters and cash across Iran into Afghanistan and Pakistan.

Unlike drug-smuggling operations that occur along the same border, al-Qaeda’s trafficking in fighters and dollars bears an official stamp of approval, said Cohen, the Treasury undersecretary.

“They are operating under an agreement with the Iranian government,” Cohen said.