Foreign fighters believed to be linked to so-called Islamic State are among militants killed in a southern Philippine city, officials say.
The military has been conducting air strikes in Marawi, on Mindanao island, after it was overrun by jihadists.
The region is a stronghold for the local Maute group, which has pledged allegiance to IS.
Analysts say it is a rare admission by authorities that foreigners are now fighting alongside local militants.
President Rodrigo Duterte said the presence of foreign fighters was proof that IS had gained a foothold on Mindanao.
Officials said that six jihadists, including Indonesian and Malaysian citizens, were killed as the army continued its operation in Marawi, a mainly Muslim city in Lanao del Sur province.
What is happening in Marawi?
Fighting erupted after the army tried to capture top militant leader Isnilon Hapilon, a leader of the Abu Sayyaf militant group. He has pledged allegiance to IS and Philippine Solicitor General Jose Calida said IS had designated him its leader in the Philippines.
When the raid failed, dozens of gunmen came out on to the streets of Marawi, reportedly flying IS flags. Buildings were burned, prison inmates freed and hostages taken as the militants battled troops across the city.
At least 11 soldiers and 31 militants had been killed, a military spokesman said. It is not clear if any civilians are among the dead. Thousands of residents have fled from the city.
“We were preparing for exams and we could hear the gunfire and bombs,” one student who evacuated told Reuters news agency. “We were so scared and so were our Muslim brothers and sisters. We were sure they would get to us.”
President Duterte imposed martial law in Mindanao on Tuesday in response to the violence.
Martial law allows the use of the military to enforce order, and the detention of people without charge for long periods. Mr Duterte said it was needed to safeguard national security.
What is the IS link?
Mindanao is home to several Muslim rebel groups fighting for greater autonomy. The main ones are now holding peace talks with the government but some smaller, more hardline groups remain active.
Links between some of these groups and those from Indonesia and Malaysia go back many years, predating the formation of IS.
But Mr Calida, the solicitor-general, said domestic rebels had subscribed to the ideology of IS and the situation was evolving.
“What is happening in Mindanao is no longer a rebellion of Filipino citizens. It has transmogrified into an invasion by foreign fighters,” he told a news conference. “They want to make Mindanao part of the caliphate.”
The admission confirms what observers see as moves by IS targeting Muslim-majority parts of the southern Philippines to establish a stronghold in South-East Asia.
“It is clear that the number of men from both Indonesia and Malaysia who have travelled to Mindanao has increased over the past year,” Sidney Jones, director of the Institute for Policy Analysis of Conflict in Jakarta, told the BBC.
“And it’s crucial that the government acknowledges that there is a serious IS problem in the Philippines,” she said, saying much better co-ordination between local and national authorities was needed to deal with the situation.
She warned that images of militants in Marawi were already having an impact on social media, working as PR for the militant groups. “There’s a lot of praise and enthusiasm,” she said.
A Philippine military spokesman, however, said that while the groups in Marawi were inspired by IS, they had not seen “any concrete evidence of material support from IS”.
With fighting ongoing in Marawi, Mr Duterte said on Friday he was willing to talk to the militants. “My message mainly to the terrorists on the other side is we can still solve this through dialogue,” he said.
But he has also indicated that martial law could be expanded to the rest of the country if he felt it was necessary, a potentially controversial move in a nation that spent almost a decade under martial law under Ferdinand Marcos.
On Friday, former President Fidel Ramos, who served under Marcos but then helped oust him, warned against the use of martial law.
“Let us not talk about spreading it to the… rest of the Philippines. Let’s talk about confining it to the part of Mindanao and making it smaller and smaller,” he said.