The attack on 215 Maiwand Corps in southern Helmand province ended after almost 20 hours, the provincial governor's media office said in a statement.
At least 20 militants were killed in the attack, the statement said.
Governor’s media office also said five security force members were killed and 12 others wounded in the attack.
The attack started at 2am on early on Friday morning, sources said.
Taliban has claimed responsibility for the attack.