The attack against the camp in Tazalit, in the Tahoua region some 300 kilometres northeast of the capital Niamey, took place in broad daylight yesterday.
"Some 30 to 40 heavily armed men speaking in Tuareg carried out the attack, killing 22 soldiers," the official, who asked not to be named, told AFP.
He said the attack was "probably carried out by jihadists."
The UN refugee agency, which confirmed the death toll, said in a statement that five soldiers were also hurt in the attack, while three managed to escape.
More From This Section
They left two hours later after seizing three vehicles, including an ambulance, as well as weapons, food and clothing.
The UN refugee agency says more than 50,000 Malians have sought refuge in Niger.
Despite a peace accord and a 2013 international military intervention, large tracts of Mali are still not controlled by domestic or foreign troops and remain subject to attacks by jihadist groups.