"More than 500 domestic and foreign militants attacked the army forces on Monday night," Defence Ministry spokesperson Zahir Azimi said.
"The attack left 49 militants dead and scores injured," he wrote on his Twitter account.
He said five soldiers were killed, six wounded and one was captured by the insurgents.
Elsewhere, two foreign troops were killed by rebel attacks in eastern Afghanistan, the Nato-led military alliance said on Tuesday.
The International Security Assistance Force said the troops were killed on Monday, but did not give details about the nationalities or the location.
Five British soldiers were killed two days before when their helicopter crashed in the southern province of Kandahar. Nine Nato troops were killed in April, and 25 have died so far this year in Afghanistan.