The soldier, who recently immigrated to Israel from America, was initially jailed for 11 days after eating a sandwich containing pork, which is forbidden by Jewish dietary law, public radio reported.
But news of his punishment spread quickly on social media, sparking a public outcry which prompted the army to revoke the punishment, admitting it had made a mistake.
"The bottom line is that we were wrong," wrote army spokesman Brigadier General Moti Almoz on his official Facebook page on Tuesday.
Read:San Diego school serves halal food after students go hungry
"The punishment which was given to the soldier was cancelled and he will be released home," he said.
"On the one hand, the IDF (army) will continue to keep kosher but we not poke our noses into soldiers' sandwiches," he wrote acknowledging there were tensions within Israeli society but saying the army had a "place for everyone."
Public radio said the offending sandwich was given to him by his grandmother who lives on a kibbutz and who had offered to take his place in jail.
Army radio quoted one of his uncles as saying he was "stunned" by the decision to jail his nephew over the contents of his lunchbox.
Known as "kashrut", Jewish dietary law bars consumption of certain foods such as pork and shellfish, and also prohibits the mixing of meat and dairy products.
Animals must be slaughtered ritually under the supervision of a rabbi.
As an official Israeli institution, the army is bound to respect such dietary rules in its mess halls.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ