The town is in Cabo Delgado, a gas-rich northern province where Islamic State-linked militants launched an insurgency in 2017. Despite a large security response, there has been a surge in attacks since January this year.
Two security sources told Reuters that hundreds of fighters are believed to be involved in the latest attack.
"Macomia is under attack since this morning. Fire exchange still continues," Nyusi said at around 1000 GMT, adding that the militants initially withdrew after about 45 minutes of fighting, but then regrouped and came back.
Friday's attack appeared to be the most serious militant attack in the area in some time.
A regional force from the Southern African Development Community (SADC), which deployed in Mozambique in 2021, started withdrawing last month as its mandate ends in July.
Piers Pigou, head of Southern Africa Programme at the Institute for Security Studies, said the attack on the Macomia district headquarters validates concerns over a security vacuum opening up with the drawdown of the southern African troops.
"Claims that the province has been for the most part stabilized are evidently not accurate," he told Reuters.
Nyusi said that attacks can take place in such periods of transition, and that he hoped the SADC forces would be able to step in and help. It was unclear if they were still deployed in the area or involved in the fight.
Rwanda has also deployed troops to Mozambique to help fight the insurgency.
Figures released by the International Organization for Migration in March show over 110,000 people displaced since the end of last year, amid escalating violence in the province.
The offensive comes as French oil company TotalEnergies TTEF.PA is seeking to restart a $20 billion liquefied natural gas terminal in Cabo Delgado that was halted in 2021 due to the insurgency. That project is some 200 kilometers (124 miles) north of Macomia, the town under attack.
ExxonMobil, with partner Eni, is also developing an LNG project in northern Mozambique and said last week that it was "optimistic and pushing forward" as the security situation had improved.