Mohamed Ibrahim had been a learning support teacher at Newman Catholic College in Harlesden for two years when he was appointed to the post.
The 64-year-old has also taken up the role of minister for foreign affairs.
Head teacher of the school, Richard Kolka, said he was “awestruck” by the news.
Mr Kolka said when the school’s summer term ended in July he had no idea Mr Ibrahim was going anywhere.
“The first I heard about it was on 1 August when a colleague sent me a text to tell me of his [Mr Ibrahim’s] appointment,” Mr Kolka said.
“He emailed and asked if he could have permission not to return to school.
“I usually ask for one-month’s notice so I had to waive that particular protocol.”
In his email, Mr Ibrahim said: “I was unexpectedly called to my country Somalia during the school holidays and appointed as a deputy prime minister and the minister for foreign affairs at a time when the country was facing humanitarian crises such as drought and famine.
“I have already faced the challenges of this new job and have taken part in the FAO (Food and Agriculture Organisation) conference in Rome, the Islamic conference in Istanbul and going to Ethiopia for the African Union to appeal for humanitarian relief for Somalia.
“I will always have Newman Catholic College in my heart and won’t forget my wonderful colleagues.”
‘Hardship and suffering’
On congratulating his former member of staff, Mr Kolka said: “I was both amazed and awestruck by your news. What an honour for you, but also what a responsibility!
“You deserve all the best of good fortune as you seek to serve your country that has endured so much hardship and suffering.”
Somalia has suffered decades of fighting and has not had a functioning national government since 1991.
The UN-backed authority which Mr Ibrahim has joined controls the capital, Mogadishu, but hardly anywhere else.
Most southern and central areas are dominated by the al-Qaeda linked militants, al-Shabab, which has staged several suicide attacks on government officials.
They are severely preventing many Western aid agencies from assisting those suffering from famine in areas they control.
Source: BBC London