The governor of Nigeria's commercial hub of Lagos has lost his bid for re-election, officials said on Wednesday, after a tense race highlighting divisions in the country's ruling party. Lagos, a megacity of more than 20 million people, is the beating heart of Nigeria's economy and home to a thriving business sector and flourishing creative scene.It forms the backbone of Nigeria's southwest swing region - the keystone to winning a second term for incumbent President Muhammadu Buhari and his All Progressives Congress (APC). But despite a second term being almost assured for state governors, in Lagos incumbent Akinwunmi Ambode failed to secure the APC ticket to stand for re-election in March next year.In primaries held on Tuesday, Ambode won 72 901 votes while former state commissioner Babajide Sanwo-Olu secured 970 851.The backing of APC leader and political godfather Bola Tinubu for Sanwo-Olu was seen as key to the surprising reverse for Ambode.In the run-up to the Lagos primary, speculation was rife that Tinubu was butting heads with Buhari over who should be the APC candidate.At the same time, Ambode made headlines for defiantly refusing to stand down.* Sign up to News24's top Africa news in your inbox: SUBSCRIBE TO THE HELLO AFRICA NEWSLETTERFOLLOW News24 Africa on Twitter and Facebook. Confusion had mounted because the date for the primary, which was originally slated for last Saturday, was changed three times. On Tuesday election officials initially said the primary was not fair but by Wednesday had declared Sanwo-Olu the winner. It was not immediately clear if Ambode would accept the results or leave the APC, potentially setting up a scenario that could split the vote and weaken Buhari's chances in the state.At the last presidential election in 2015, Buhari narrowly won Lagos with 54.9% of the vote.Politics in Nigeria is characterised by patronage and politicians easily change parties when their personal interests are threatened.Buhari faces a formidable challenge from the main opposition Peoples Democratic Party (PDP) which will this weekend pick a flag-bearer from an array of candidates, including former vice president Atiku Abubakar and Senate president Bukola Saraki.