Updated

An Israeli court on Wednesday released the Palestinian deputy prime minister, the highest ranking Hamas official to be freed following a crackdown on the Islamic militant group. But the court temporarily banned him from going to his government office in the city of Ramallah, his lawyer said.

Nasser Shaer was arrested on Aug. 19 but never charged, his lawyer, Osama al-Saadi, said.

The Israeli army and the police confirmed that an Israeli court ordered Shaer freed on Wednesday. He was headed back to his home in the West Bank city of Nablus, al-Saadi said.

"There was no basis for his arrest. This is natural," he said, referring to Shaer's release.

CountryWatch: Israel | Egypt | Syria | Iran

Israel rounded up dozens of Hamas political leaders after militants linked to the group captured an Israeli soldier on June 25. The arrests appeared to be an Israeli effort to collect bargaining chips to force the militants to release the captured soldier. Israel also launched a widespread military offensive in Gaza to put further pressure on the militants.

Egypt has unsuccessfully tried to broker a deal exchanging the soldier, Cpl. Gilad Shalit, for hundreds of Palestinian prisoners in Israeli jails.

Shaer managed to evade arrest for several weeks this summer before Israeli troops burst into a house where he was hiding in the West Bank city of Ramallah.

A total of 30 lawmakers and four Cabinet ministers remain in custody, charged with belonging to an illegal group. On Monday, another military court in the West Bank declined to release 21 of those detained officials on bail. A hearing for the 13 others is scheduled for Oct. 5.

Under Wednesday's court order, Shaer must stay out of Ramallah, home of the Palestinian government, for two weeks.

Ghazi Hamad, spokesman for the Hamas-led government, said Shaer's detention was "political and illegal."

Hamad said the charges against the other officials were "fabricated," and they should also be released.

"If this was a good will gesture, it is better to release the other ministers and lawmakers, whose arrest was political extortion from the outset," he said.

Visit FOXNews.com's Mideast Center for more in-depth coverage.