Abd Allahi Ganey Frimbi urged Somalis to take up arms if the troops are deployed without the consent of the transitional parliament and leaders of armed factions that currently control the country.
It is not clear how much support Frimbi enjoys or if any of Somalia's clan-based militias will heed his call.
But tensions are rising in Somalia, where clan chiefs turned politicians have said they are prepared to accept peacekeepers from the African Union and the Arab League but not troops from neighbours.
Frimbi was addressing hundreds of demonstrators in Mogadishu on Tuesday opposed to plans by officials from seven African countries who have agreed to send a 6800-strong regional force before a fuller African Union peacekeeping mission.
Call to arms
The force will be deployed from the end of April and will include troops from neighbouring Ethiopia, Djibouti and Kenya in a mission that will last for nine months.
The decision by must be endorsed by foreign ministers who will meet in Kenya on 16-17 April.
"I urge you to take up your arms and be ready for a possible war against your country, religion and sovereignty," Frimbi told a rally organised by regional officials, leaders of civil-society groups and representatives of armed factions.
"I urge you to take up your arms and be ready for a possible holy war against your country, religion and sovereignty"
Abd Allahi Ganey Frimbi,
Self-declared governor of Mogadishu
Somali ministers, Islamic clerics, some residents and the US State Department have warned that sending troops from neighbouring countries will derail fragile efforts to end a 14-year civil war in the Horn of Africa nation.
Clan chiefs and lawmakers from a clan that controls the capital offered on Sunday to withdraw 15,000 fighters from Mogadishu to guarantee the security of the country's government - but only if troops from neighbouring countries are not sent.
Ethiopia actively supported Somali factions with money and weapons in the civil war that started in 1991, and its troops could seek to advance Ethiopian interests if deployed in the Horn of Africa nation, some Somali lawmakers said.
Somalis also remember the war they lost in 1977 over control of Ethiopia's southeastern Ogaden region, largely inhabited by ethnic Somalis.
The transitional government has
asked the AU for peacekeepers
The Somali army never recovered from the defeat, a fact that eventually helped clan chiefs to overthrow Muhammad Siad Barre in 1991.
Somalia's government is based in neighbouring Kenya because Mogadishu is considered unsafe.
Demonstrators on Monday carried banners screaming "Nobody can compel us to accept troops from neighbouring countries including Ethiopia, which is the enemy number one of Somalia".
Prime Minister Ali Muhammad Gedi's cabinet asked the African Union and Arab League earlier this month to send between 5000 and 7500 troops with a one-year mandate to protect the government as it organises a police force and army.