Williams himself criticised the arrests, tweeting on Tuesday: "It's beyond sad these kids were arrested for trying to spread happiness."
Following her release, one of the dancers, Reihane Taravati wrote on her Instagram account: "Hi, I'm back, thank you @pharrell and everyone who cared about us." "Love you all so much and missed you so much."
Tehran's police chief, Hossein Sajedinia, said he had ordered the arrest of the six young people featured in the clip because they had created an "obscene video clip that offended the public morals", according to the ISNA news agency.
Earlier, the six young people appeared in a programme broadcast by Iran's state TV, in which they were described as actors, and apparently expressed their regret at making the video.
"They [the video's makers] had promised us not to publish the video," said one of the women in the footage. She goes on to tell the police the group was tricked into making the Happy video - jarring with the positive message at the end of their YouTube post.
Iranians caught dancing to 'Happy' arrested:
Last week, a Facebook page entitled My Stealthy Freedom, which shows Iranian women without their hair covered, quickly went viral and garnered 331,000 likes.
These examples of defiance on social media comes as many liberal Iranians hope President Hassan Rouhani, who has eased the country's antagonistic stance with the West, might also relax the Islamic Republic's social strictures.
In a tweet on Wednesday, Mr Rouhani appeared to express support for the six.
"#Happiness is our people's right. We shouldn't be too hard on behaviors caused by joy," he wrote on his English language Twitter account, without specifically referring to the video.
However, Mr Rouhani has delivered few social reforms since his election last year, apparently intent on conserving his political capital for seeking an end to the nuclear dispute, that has involved a politically risky engagement with the United States.
- Independent