An installation including a mask representing Israel's Prime Minister Benjamin Netanyahu is set during an anti-government protest calling for captives release in front of the Israeli Defence Ministry in Tel Aviv . AFP
Eliezer Feldstein was detained along with three other people, including security officials, said the court in the coastal city of Rishon LeZion.
News of the case has led the opposition to question whether Netanyahu was complicit in the leak.
Critics have long accused the premier of stalling in truce negotiations and prolonging the war to appease his far-right coalition partners.
Israel's domestic security agency and the army launched an investigation into the breach in September after two newspapers, British weekly The Jewish Chronicle and Germany's Bild tabloid, published articles based on the classified military documents.
One claimed a document had been uncovered showing that then Hamas leader Yahya Sinwar -- later killed by Israel -- and the captives in Gaza would be smuggled out of the territory into Egypt through the Philadelphi Corridor along the Gaza-Egypt border.
The other was based on what was said to be an internal memo from the Hamas leadership on Sinwar's strategy to hamper talks towards the captive's release.
The first document leaked turned out to be fake, and the internal memo was in fact written by lower-level Hamas members, Israeli media reports said.
The Israeli court said the release of the documents ran the risk of causing "severe harm to state security".
"As a result, the ability of security bodies to achieve the objective of releasing the hostages, as part of the war goals, could have been compromised," it added.
Key opposition leader Yair Lapid told journalists on Sunday the details of "the serious security affair in Netanyahu's office should alarm every Israeli".
"This affair originated in the prime minister's office, and the investigation needs to determine whether it was not under the prime minister's orders," Lapid added.
"According to suspicions, Netanyahu's associates leaked secret documents and forged classified documents to undermine a possible hostage release and to build a media campaign against the hostages' families."
Another leading opposition figure, Benny Gantz, said: "This is not a case of suspected leaks but rather profiteering with state secrets for political purposes."
On Friday, Netanyahu denied the allegations, saying "the document published by Bild had never arrived" at his office.
Without mentioning Feldstein by name, he said the former aide "had never taken part in security meetings or consulted confidential documents".
Short link: