The mob was asking the police to hand them over the youth, who had uploaded the derogatory material on the internet and was subsequently arrested last week, police said.
They said the derogatory material posted on the social networking sites had hurt their religious sentiments, police said.
"When the accused was being taken to the court, the rampaging mob started pelting stones at Sarpatnaka police station. They were demanding to beat the youth. Four policemen sustained injuries in the stone pelting," Superintendent of Police (SP) D N Patel of Kutch-Bhuj district said.
A case of rioting has been registered against the mob and further probe is on, police said.