The alleged message from Zawahiri appeared Tuesday on the website of Somali militant group al-Shabab, which is fighting African forces that support Somalia's government.
The speaker, talking in Arabic, references al-Shabab's loss of the port of Kismayo, an indicator the recording was made recently.
He urges jihadist fighters to disregard the number of troops and attack them through ambushes and suicide bombings.
Al-Shabab made a formal alliance with al-Qaida in February but has suffered continuous battlefield losses to pro-government troops from Kenya, Ethiopia and the African Union.
Kismayo was the last major town controlled by the group, which once ruled most of southern and central Somalia.
Somalia's newly-installed central government hopes to restore order to a country that has not had a stable central authority since 1991.
A purported message from al-Qaida chief Ayman al-Zawahiri calls for a campaign of guerrilla warfare against foreign troops in Somalia.