DUBAI, United Arab Emirates (AP) — Iran's president will likely swagger into New York next week in much the same style as past visits for the annual U.N. General Assembly: ready to take his jabs at America on its home turf.

But any outward confidence on the big U.S. stage contrasts sharply with his increasingly public power struggles back in Iran that could shape the tone of the Islamic republic for years to come.

President Mahmoud Ahmadinejad — who was a divisive figure in Iran after his disputed re-election last year — is now the great divider among the conservative leadership as the threat fades from the battered and dispirited opposition, analysts say.

"They have generally gotten rid of the Green Movement and now they are fighting among themselves," Mehrzad Boroujerdi, an expert on Iranian affairs at Syracuse University, referring to the opposition movement.

Just in the past week, Ahmadinejad was hit with a series of slaps — including the judiciary commandeering the exit rules for jailed American hiker Sarah Shourd. It adds up to more evidence that the old guard clerics and others are pushing back harder against Ahmadinejad's political hungers.

Their complaint basically is that Ahmadinejad is trying to redraw the political flow chart. Since the Islamic Revolution, it's been easy to follow: the ruling clerics on top and the elected officials — including the president — notches lower.

Ahmadinejad appears to be constantly testing the system — and possibly the patience of theocracy — by trying to expand the autonomy of his office in policy decisions and filling key posts. There is also a question of his biggest ally, the hugely influential Revolutionary Guard, and whether it wants to stretch its portfolio even further.

The Guard already controls almost everything of importance in Iran — from protecting the nuclear program to directing the Basiji paramilitary corps. These were the front-line forces set loose against protesters who alleged that ballot fraud handed Ahmadinejad another term in office until 2013.

The Guard's widening presence in Iranian affairs is nudging the country — in some eyes — closer to the values of the generals and away from the mullahs. It's been a repeated theme of the opposition and Western officials such as Secretary of State Hillary Rodman Clinton.

Iran's opposition leader, Mir Houssein Mousavi, has warned that Iranian society is becoming "more militarized."

Now there appear to be more rumblings from the top.

A video currently making the rounds on the Internet shows a student leader reading a statement at a gathering with Supreme Leader Ayatollah Ali Khamenei this month urging Ahmadinejad to remain true to the "precepts" of the Islamic Revolution.

In the coded language of Iranian politics, it's widely seen as another way for Khamenei to send indirect warnings to Ahmadinejad to remember who is in charge.

A much clearer rap came this week when Khamenei forced Ahmadinejad to cancel the appointments of six special international envoys. Ahmadinejad apparently had not bothered to clear the postings with Khamenei, who has warned the president to avoid "parallel efforts" in foreign policy.

There's no suggestion that Ahmadinejad could be pushed from office by the theocrats. Khamenei made a tactical decision amid the postelection mayhem to embrace the official results and turn his back on the demonstrators.

But the signs of high-level rifts have wide spillover. They bring questions about whether Iran can continue to speak in a unified voice in its disputes with the West over its nuclear program. Or even how much Ahmadinejad's statements — including his expected interviews and speeches in the U.S. — are freelance policy or sanctioned by the turbans at the top.

This was once a given. Even Ahmadinejad's predecessor, reform-minded President Mohammad Khatami, did not ruffle the clerics by suggesting he was outside their rules.

"There is only one thing clear: Iran is no longer the topdown structure it once was," said William O. Beeman, a University of Minnesota professor who has written on Iranian affairs. "It's much more fluid."

And, at times, messy. The zigzag path over releasing hiker Sarah Shourd offered up the internal tensions for the world to see.

Khamenei and the judiciary he controls eventually ruled the day after bigfooting Ahmadinejad to take over the release of the American and demand $500,000 in bail, which was paid after mediation by Oman to clear her freedom Tuesday after more than 13 months in custody. Two other Americans detained with her — Shane Bauer and Josh Fattal — remain jailed in Tehran, accused of spying.

But there also was an added element of inside intrigue in the case. The judiciary head, Ayatollah Sadeq Larijani, is part of the most powerful one-two combination against Ahmadinejad within the establishment.

Larijani's brother, Ali, is parliament speaker and Iran's former nuclear negotiator — and considered one of Ahmadinejad's leading rivals among Iranian conservatives.

Meir Javedanfar, an Israel-based author and analyst on Iranian affairs, said the Shourd case suggests that Khamenei may be inclined to move quicker to rein in Ahmadinejad in the future.

Khamenei "has two main goals — first and foremost, stability in the system; second, the nuclear program," he said. "By settling this (Shourd) matter as soon as possible, he put out flames which could have become another fire in his backyard."

Still, Ahmadinejad may reap some reflected glory for Shourd's release. He can head to the opening of the U.N. General Assembly on Sept. 23 with Shourd as a talking point. Yet it also shows a bit of Ahmadinejad's contradictory nature.

In the past, he has said the detained Americans could be valuable as bargaining chips to exchange for Iranians that Tehran alleges are held by the U.S.

In an interview with NBC News on Wednesday, Ahmadinejad made an indirect — but clear — reference to supporters of Israel as the main source of tensions between the West and the Muslim world.

"I should say there is no conflict between the two cultures," he said. "They should find where the problem is. I ask this question. Do the people of the United States hate the ... Muslims? Is that so? That's not true. Muslims do not hate Americans, either."

He also gave perhaps a passing nod to his own challenges at home by noting that various groups keep pressure on President Barack Obama.

"Do you really think President Obama can do anything he wishes to?" he said.