LAGOS (Reuters) - The governor of Nigeria’s commercial hub Lagos, a prominent ruling party figure, lost his bid on Wednesday to seek a second term following a primary selection process that exposed internal divisions in a crucial state months ahead of polls next year.

FILE PHOTO: Lagos State Governor Akinwunmi Ambode (C) inspects a guard of honour at the military arcade during a ceremony marking the army Remembrance Day in Lagos, Nigeria January 15, 2017.REUTERS/Akintunde Akinleye/File Photo

Lagos state, with a city of some 23 million inhabitants, is the driving force in one of Africa’s biggest economies and a key election battleground in the southwest.

The region’s support for President Muhammadu Buhari and his ruling All Progressives Congress (APC) party proved to be crucial in the 2015 presidential and gubernatorial races that swept the leader to power.

But there have been signs of waning support for Buhari and his party in the southwest, most recently in the APC’s narrow win last week in the governorship election in Osun state. And the Lagos primary race exposed rifts within the party.

Akinwunmi Ambode, who took office in 2015, was defeated by Babajide Sanwo-Olu in the APC’s primaries for gubernatorial elections to be held in March 2019, just weeks after February’s presidential election in which Buhari will seek a second term.

“I ... declare Babajide Sanwo-Olu the winner,” said Clement Ebri, chairman of the APC Lagos governorship primary committee, at a briefing broadcast on national television.

The hard fought contest in Lagos was at times rancorous and prompted Ambode to call for unity in the wake of his defeat.

In a televised address he urged APC members to “unite behind the candidate of the party so that we can continue to move this state forward”.

The governor of Lagos is a powerful figure who controls a budget bigger than many African countries.

Ambode’s defeat follows weeks of reports in local media that he had lost the support of Bola Tinubu, himself a former Lagos state governor and a political godfather in the region.

Tinubu’s backing for Buhari in the predominantly Christian southwest played a pivotal role in the northern Muslim securing his first term, delivering much needed support beyond the president’s core northern base.