New York: Six young Iranians who were arrested for posting a YouTube video of themselves dancing on Tehran rooftops to Happy, the globally infectious pop song, were released on bail on Wednesday, as new details emerged of their possible mistreatment while incarcerated amid an outpouring of sympathy — including a subtly supportive Twitter post from Iran’s president.

The arrests of the six, who were all younger than 25 and included women not wearing their mandatory headscarves, were carried out over the weekend. They were taken into custody just as the president, Hassan Rouhani, was giving a speech arguing that Iranians should embrace the Internet instead of viewing it as an insidious Western threat to Islamic morals.

The six were shown on state television on Tuesday, backs to the camera, apologising for having made the video, which was uploaded on YouTube in April and received more than 165,000 hits. The television broadcast also included an admonition from Tehran’s police chief, Hussain Sajedi, who told all young Iranians never to make such videos.

The episode appeared to reflect a broader clash between Iran’s religious conservatives and the faction represented by Rouhani, a relatively moderate cleric who was elected nearly a year ago partly on pledges to ease some of the political and social restraints in Iran, including censorship of the Internet. Despite those pledges, many restrictions remain firmly in place, enforced by military and judicial authorities that view Western influence with suspicion.

The Happy video was made as part of a highly successful international campaign by its original creator, Pharrell Williams, an American singer-songwriter, who called upon people to replicate it and post their videos online.

News that the six Iranians were arrested incited an indignant reaction by rights groups such as Amnesty International and by Iranian-Americans. These critics characterised the action as baseless paranoia or worse, part of a broader, deliberate attempt to sabotage Rouhani’s efforts, including his negotiations on Iran’s disputed uranium enrichment programme that has left the country basically ostracised by the West.

“There are forces within Iran’s government who want to keep the Iranian people isolated from the world,” said the National Iranian American Council, a Washington-based advocacy group. Its president, Trita Parsi, said in a Twitter post that Iranians cannot be forced to live in a world where “enrichment is a right, but happiness is not.”

Williams also reacted, posting on his Facebook page: “It is beyond sad that these kids were arrested for trying to spread happiness.”

Rouhani, who has his own Twitter account, commented on the arrests for the first time on Wednesday by retweeting a post he had first made after he was elected: “Happiness is our people’s right. We shouldn’t be too hard on behaviours caused by joy.”

It was unclear precisely what charges the six faced. But Iranwire, a news service run by expatriate Iranian journalists that was among the first to report the arrests, said on Wednesday that their families had each been ordered to pay bail of at least 30 million toman — the equivalent of more than $10,000 (Dh36,729) — and that the six were likely to be summoned to court later.

Iranwire also reported the six had not been allowed to use the bathroom on the first day of their arrests, were placed in solitary confinement on the second day and were extensively interrogated about their comments to the foreign news media.

Hadi Ghaemi, the executive director of the International Campaign for Human Rights in Iran, a New York-based advocacy group, said the defendants were likely to be charged with “promotion of immoral acts” and “distribution of images disturbing public chastity.”

— New York Times News Service