The attack on Wednesday evening occurred in Lidjungo village in the Nangade district, said a local source based in Mozambique's northern Cabo Delgado.
One policeman and six civilians were killed in the attack, including two children.
Islamist fighters have targeted remote communities in the gas-rich, Muslim-majority Cabo Delgado province since October 2017, killing more than 250 people and forcing thousands from their homes despite a heavy police and military presence in the area that borders Tanzania.
According to SITE Intelligence, which monitors jihadist activity, Islamic State issued a statement late on Friday claiming involvement in the Wednesday attack.
This is its second IS claim for an attack in Mozambique, targeting the volatile northern region. The first was on June 3.
"The soldiers of the caliphate assaulted barracks of the crusader Mozambican army, in the Nangade area, in northern Mozambique, two days ago," said the statement, according to a SITE translation.
The group claimed to have clashed with the military "killing and wounding a number of them and forcing the remainder to flee".
It said fighters seized weapons and ammunition.
The group first claimed involvement in northern Mozambique last month, saying it carried out an attack that took place in Metubi village, about 150 kilometres east of Nangade.
The police and government have a policy of not commenting on any insurgent activity, even if attacks are confirmed by local residents.
The identity of the militant Islamists staging attacks in northern Mozambique remains unclear and the motives unknown.
Analysts have expressed doubts over claims by the Islamic State, suggesting that it is unlikely that the group would have direct contact with fighters in Mozambique.