An Electoral officials carries a ballot box with counted votes for submission during the gubernatorial election at Ido Oshun, Osun State in southwest Nigeria, on July 16, 2022. AP
Osun is among eight of Nigeria's 36 states where governorship elections are not being held at the same time as the rest of the country because of legal challenges to previous results.
The Independent National Electoral Commission (INEC) said Senator Ademola Adeleke of the Peoples Democratic Party (PDP) polled 403,371 votes to unseat incumbent APC Governor Gboyega Oyetola, who scored 375,027 in Saturday's ballot.
"I declare that Ademola Jackson Nurudeen Adeleke of the PDP, having satisfied the requirements of the law, is hereby returned elected," said INEC returning officer Oluwatoyin Temitayo Ogundipe in Osogbo, the state capital.
Adeleke, 62, won 17 of the state's 30 local government areas while Oyetola won in 13.
The announcement was greeted with spontaneous celebrations on the streets of the state capital as PDP supporters started singing and dancing. Motorists blared their horns on the roads.
Election observers said the polls which opened early with a large turnout was peaceful, but added that cases of vote-buying were rampant.
Of the 15 parties that vied for the seat, only four candidates were frontrunners. They were the APC's Oyetola who was seeking a second term, Adeleke of the PDP, Akin Ogunbiyi of the Accord Party and the Labour Party's Yusuf Lasun.
However, it was a straight race between old political foes Oyetola and Adeleke -- who lost by less than 500 votes after a run-off four years ago.
Described locally as a "dancing senator" because of his penchant for partying, Adeleke is an uncle of celebrated Nigerian superstar singer Davido, who joined him on the campaign.
The PDP flagbearer comes from a wealthy political family. His father was a senator in the 1980s while his late brother, Isiaka, was the state governor from 1992 to 1993.
Another brother, Deji, is a billionaire oil and shipping mogul and Davido's father.
Davido was in the state to mobilise the youth, including his supporters and fans, for his uncle.
The ballot was seen as a battleground for Nigeria's leading parties to test support for their presidential hopefuls ahead of the February 2023 election as Buhari steps down following eight years in office.
The APC has chosen former state governor Bola Ahmed Tinubu as its presidential candidate.
The APC's loss in Osun is a blow to Tinubu's regional influence.
Tinubu, a Muslim from the southwest, faces a tough challenge from PDP candidate Atiku Abubakar, a northern Muslim.
Another frontrunner is the Labour Party's Peter Obi who has been enjoying growing support among the younger generation in a bid to break the APC and PDP dominance.
Last month, the APC won a governorship vote in nearby Ekiti state with a landslide.