The Somali government thought it had slammed the door on Iran after earlier reports emerged that Tehran was recruiting terror merchants. That was in 2016 when Mogadishu severed diplomatic ties.
But now Somali officials have been thrown back into an awkward corner after reports emerged that Yemen's Houthi rebels, heavily backed by Iran, have established a 'working relationship' with local militants al-Shabaab.
When the reports first emerged this week as chatter among security chiefs, including American defence officials, it came as both a shock and a reality check.
The Houthi rebels have a different ideology to that of al-Shabaab, which has also pledged allegiance to al-Qaeda.
It came as Somalia's National Security Adviser, Hussein Sheik-Ali, hit back at another claim that al-Shabaab was regaining ground in parts it had initially liberated. He dismissed the claims as "rubbish".
What provoked the strong reaction from the senior Somali adviser were reports that senior US defence officials, speaking on condition of anonymity to discuss sensitive security matters, said the military campaign in central Somalia had put al-Shabaab "on the back foot" over the past two years. The report appeared in the Voice of America bulletin.
Somalia is at a crossroads over how to pick up the pieces of its security after the African Union Transitional Mission in Somalia (ATMIS) pulls out by December. Mogadishu has already asked both the African Union and the United Nations to endorse a slower drawdown, with fewer troops leaving in batches.
Both the issue of tougher sanctions against al-Qaeda-linked terrorist groups and the future of ATMIS were due to come before the United Nations Security Council (UNSC).
But it is the question of the Houthis that may be more troubling. US defence officials suggested this week that it should be taken seriously.
Washington has imposed sanctions on both the Shabab and the Houthis, particularly after the latter began attacking ships passing through the Red Sea earlier this year in retaliation for Israel's targeting of Hamas in Gaza.
Around the same time, piracy off the coast of Somalia began to rise from near zero last year.
According to the European Union Naval Force, which runs Operation Atalanta off the coast of Somalia and the Red Sea, there have been 19 attacks on ships this year, four of which were pirated. There was one pirate attack at the end of last year.
A link between these two sides crosses an ideological bridge that was initially thought impossible. The Houthi follow a Shiite sect of Islam, while al-Shabaab seek to strictly implement the text of the Sunni sect of Islam.
When Somalia cut ties with Iran in January 2016, Somali President Hassan Sheikh Mohamud accused Iran of implementing a 'subversive agenda' through humanitarian efforts.
Mohamud insisted that the country's intelligence service was monitoring Iranian efforts to spread Shiite ideologies using the Iranian Red Crescent and the Khomeini Charitable Foundation. This forced Somalia to close the Iranian embassy and suspend humanitarian aid.
Sheikh Nur Barud, then chairman and spokesman of the Somali Association of Muslim Clerics, agreed with the government in suspending relations with Iran, pointing out that the Shiite state and its agencies tended to spread the doctrines of their sect, complicating the security and welfare of the already beleaguered people.
When rumours circulated that the Iranian Red Crescent was using its centre in Mogadishu to perform marriage ceremonies for thirty couples at a time, of course in line with Shiite doctrine, Al-Shabaab reacted bitterly.
Al-Shabaab spokesman Sheikh Ali Mohamed Raghe, alias Ali-Dhere, said: "Shiite doctrine is a distortion of Islam. Hence their influence is even worse than that of Christianity.