Driving cars and motorbikes, the attackers stormed Dioura army camp in the Mopti region, in the latest assault on the military as the country grapples with the spread of extremist groups and instability.
"The provisional toll is 21 bodies discovered," said a military source, in figures also confirmed by a local legislator.
10 UN peacekeepers killed in Mali attack
The attack was carried out "by terrorist groups under the command of Ba Ag Moussa, a deserter army colonel", according to the Malian armed forces.
A second military source said there was "a lot of damage".
"Our men responded. I saw at least four bodies on the ground," he said.
President Ibrahim Boubakar Keita, on Twitter, said the Malian people were "united against terrible acts", without giving any death toll.
Once a beacon of democracy and stability in Africa; Mali in recent years has been dogged by a coup, civil war and terrorism.
Extremists linked to Al-Qaeda took control of Mali's desert north in early 2012, but were largely driven out in a French-led military operation launched in January 2013.
In June 2015, Mali's government signed a peace agreement with some armed groups, but the militants remain active, and large tracts of the country remain lawless.
37 killed in hunter-farmer conflict in Mali: government
Despite the presence of UN peacekeepers, a strong French military contingent and the creation of a five-nation military force in the region, militant violence has not abated in Mali.
"Despite significant international efforts, the security situation has continued to deteriorate with an increase in the number of terrorist attacks," said UN Secretary-General Antonio Guterres in a report sent to the Security Council this month.
In 2018, there were 237 terror attacks, up from 226 in 2017 and 183 the previous year, said the report.
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