Mozambique lacks the capacity to fight its civil war, so it is dependent on foreign mercenaries, training and equipment. For historic reasons, there are three countries that want their troops in Mozambique and which Frelimo opposes.
Top of the list is the United States, which waged a Cold War proxy war against Mozambique in the 1980s and which killed a million Mozambicans. The US is the largest bi-lateral donor so has to be allowed a training mission. In the early days of the civil war, the US had not yet decided to fight a new cold war against China and Russia, and was searching for enemies. It saw Islam as a possible enemy and began to look at waging part of its war against Islam in Mozambique. Other enemies took over, so Islam became less important to the US.
Second is Portugal, the former colonial power, which wants to prove Mozambique still needs colonial troops. Portugal made the running to set up an EU training mission, which of course used Portuguese soldiers to train. But there are no boots in the war zone - neither US nor Portuguese trainers are allowed to go to Cabo Delgado to observe their students.
South Africa still sees itself at the major regional power and set up the SADC Military Mission in Mozambique (SAMIM), which Mozambique never welcomed, but had to accept because Mozambique is part of SADC. SAMIM has been in Mozambique for two years but it now leaving, which pleases Frelimo, in part because it has not been militarily effective or useful.
In early 2021 insurgents captured the gas town of Palma, which underlined the inability of Mozambique forces to win the civil war. Totally unexpectedly, President Filipe Nyusi turned to Rwanda, which had a large and well trained military which it hired out for peacekeeping. It is almost a neighbour and speaks Kiswahili, one of the languages of Cabo Delgado (and Tanzania). And its northern links are with France, the country of TotalEnergies, which is the main gas company in Mozambique. Rwandan soldiers have proved highly effective in controlling the insurgency in the gas zone. In addition to money, Rwanda President Paul Kagame successfully demanded part of the local construction and contracting sector, and also the right to extradite Rwandan political opponents who had taken refuge in Mozambique. The sudden exit of SAMIM is because SADC's latest military venture is helping the Democratic Republic of Congo (DRC) to fight the M23 rebel movement in the resource-rich eastern province of North Kivu, which borders Rwanda. But Rwanda is strongly backing M23. SADC leaders said they could not fight against Rwanda in the DRC and with Rwanda in Mozambique, so they are pulling out of Mozambique.
Finally, after the death in 2021 of Tanzania president John Magufuli from Covid (which he denied existed), the new president Samia Suluhu Hassan improved relations with all Tanzania's neighbours. This included cooperation with Mozambique on the war. Troops that had been part of SAMIM have stayed and taken effective control of the border district of Nangade, which had been controlled by insurgents.