Six Iranians arrested after a video of them frolicking to the hit song “Happy” went viral were released after President Hassan Rouhani tweeted his approval.

The self-professed moderate and social media-savvy president stepped in after Iranian police arrested the four men and two women, who were dancing and singing on an urban rooftop to the infectious hit song by American star Pharrell Williams. The video has drawn tens of thousands of views on YouTube.

And with that, the six were released, though the director of the video remains in jail. One of the women told authorities she did not know the video would be put on the web, where it attracted the attention of the hard-line police in the Islamic republic.

“They promised it wouldn’t be broadcast,” she said in an interview broadcast on IRIB2, Iranian state-run TV.

Islamic law prohibits co-ed dancing and the women appeared without proper Islamic hijab, or headscarves. Iranian police wasted no time tracking down the participants after the video hit the Internet.

“They should be certain that we were able to discover and identify the individuals in a very short time. We will certainly find out about who they are and confront them,” an officer said on IRIB2.

Williams expressed his disgust over the repressive regime in a post on Facebook.

“It is beyond sad that these kids were arrested for trying to spread happiness,” the superstar singer wrote.

In reaction to the arrests, thousands posted on Facebook and Twitter using the hashtag #FreeHappyIranians. A human rights organization also circulated a petition demanding their release.

After giving an interview to Iran’s official IRNA news agency over the weekend -- days before the arrests -- in which he defended Internet freedom, Rouhani may have felt he had to speak up for the “Happy” group.

“"We ought to see [the Internet] as an opportunity,” Rouhani said. “We must recognize our citizens' right to connect to the World Wide Web.

"Why are we so shaky? Why have we cowered in a corner, grabbing onto a shield and a wooden sword, lest we take a bullet in this culture war?" Rouhani added. "Even if there is an onslaught, which there is, the way to face it is via modern means, not passive and cowardly methods.”