Judicial Magistrate Azad Singh, who granted the relief on two bail bonds worth Rs 20,000 each, has asked the youth to cooperate with police during investigation.
The youth will walk out of jail once the bond formalities are over, officials said, adding that it may take a few hours.
The student of a Bareilly school was sent to jail by a local court yesterday after being booked under the controversial Section 66A of the Information Technology Act and for breach of peace by the Rampur police.
According to Circle Officer of Police Aley Hassan, the boy had posted comments on Facebook which could incite communal tensions and spoil peace and harmony.
In the post, Khan was targeted on the basis of a provocative remark allegedly made by him that turned out to be 'fake', police said.
"A quote was posted on Facebook on March 15 that was attributed to the cabinet minister (Khan) but it turned out to be fake," Rampur SP Sadhna Goswami said.
He was arrested on Monday on a complaint lodged with the police by the minister's Public Relations Officer Fasahat Ali Khan Shanu. A team of crime branch sleuths was constituted which nabbed the youth from his residence. Khan had defended the police action.
"A Std XII student has made objectionable comments against me on FB. Law is enforced with strictness and he has been arrested within 24 hours. Comments were made against me earlier also on FB," Khan had told reporters in Lucknow.
The youth was produced on before Singh's court which sent him on 14-day remand.
Image: Senior Samajwadi Party leader Azam Khan
Youth arrested for Facebook post attributed to Azam Khan
'My remark that Muslims won us Kargil should have been saluted'
Azam Khan wouldn't mind getting Taj Mahal demolished
Tomorrow's stars today!
Amul plans to bring camel milk to the breakfast table