Islamabad, December 18: Indian national Hamid Nihal Ansari was released from a Pakistani jail on Tuesday to be repatriated to India, six years after he was detained by intelligence agencies for entering the country illegally reportedly to meet a girl he had befriended online.

Ansari was detained by Pakistan's intelligence agencies in 2012 after he entered the country from Afghanistan and subsequently sentenced to three years' imprisonment by a military court in 2015 for possessing a fake Pakistani identity card. Pakistan to Release Indian National Hamid Ansari Today; ‘My Son Went With Noble Intentions’, Says Mother.

The 33-year-old Mumbai resident was lodged in the Peshawar Central Jail after being sentenced by the military court on December 15, 2015. His three-year jail term ended on December 15, 2018 but he was not able to leave for India as his legal documents were not ready.

On Thursday, the Peshawar High Court gave the federal government a month deadline to complete his repatriation process. The Indian national was released from Mardan jail on Tuesday and was shifted to Islamabad for his onward journey to India, state-run Radio Pakistan reported.

Ansari, a software engineer, went missing after he was taken into custody by Pakistani intelligence agencies and local police in Kohat in 2012 and finally in reply to a habeas corpus petition filed by his mother, Fauzia Ansari, the high court was informed that he was in custody of the Pakistan Army and was being tried by a military court. He entered Pakistan from Afghanistan, reportedly to meet a girl he had befriended online.

Pakistan claims that Ansari was an "Indian spy who had illegally entered Pakistan and was involved in anti-state crimes and forging documents." A two-judge Peshawar High Court bench, comprising Justice Roohul Amin and Justice Qalandar Ali Khan, on Thursday heard an appeal filed by Ansari through his lawyer Qazi Muhammad Anwar.

Anwar informed the bench that both the Ministry of Interior and authorities of prison, where he was lodged, were completely silent about his release and deportation to India.

After hearing this, Justice Khan asked the Additional Attorney General to explain how would they keep the prisoner in jail after completion of his term. An officer, representing the interior ministry, informed the court that a prisoner could be kept for one month while the legal documents were being prepared.

After knowing the legal position, the court directed the ministry to make all the arrangements within a month for releasing and deportation of the prisoner.