Sonko, 49, had been the undisputed candidate of the Pastef party, which he helped found in 2014 with a group of young people, who mostly said they were political newcomers.
But his disqualification from the presidential race in January, following three years of confrontation with the authorities, brought his more discreet deputy out of the shadows.
Bassirou Diomaye Faye, commonly known as "Diomaye," was endorsed by Sonko to replace him on the ballot.
He is running under the slogan "Ousmane mooy Diomaye"—meaning "Ousmane is Diomaye" in Wolof.
While less popular than Sonko, Faye is considered one of the favorites to win the election on March 24.
He will turn 44 the day after the first-round vote.
Ousmane Sonko
The shouts of the crowd who thronged the streets of the capital Dakar to celebrate the pair's release from prison revealed that Sonko still governed the top spot.
The firebrand rose to fame in 2016 after being removed from his post as a tax inspector for denouncing the opacity of certain public contracts and the privileges of the political class.
He has since struck a chord with Senegal's youth with his sovereigntist and pan-Africanist rhetoric and attacks on elites, multinationals and former colonial ruler France.
Sonko has drawn a passionate following partly due to his age, his deft use of social media, and his defence of traditional and religious values.
He came third in the 2019 presidential election but was disqualified from running in 2024.
Since 2021, he has been at the heart of a bitter stand-off with the state, which has triggered several bouts of unrest during which dozens were killed and hundreds arrested.
His camp and the government have blamed each other for the violence.
Sonko has always maintained there was a plot to keep him out of the 2024 election. He was sentenced twice in 2023 —receiving a suspended sentence for defaming a minister and two years in prison for corrupting a minor.
He was jailed at the end of last July on a string of other charges, including provoking insurrection, conspiracy with terrorist groups and endangering state security.
Bassirou Diomaye Faye
"Diomaye" met Sonko while working at the tax office, and later followed him to the Autonomous Union of Tax and Domains Agents, created by Sonko.
He became a key member and Secretary General of Sonko's party Pastef. Party official Top Sadikh Top described him as "a brilliant mind" who is "cool in his analysis."
Faye was imprisoned in April 2023, charged with contempt of court, defamation and acts likely to compromise public peace after posting a message critical of the justice system.
After being selected as his camp's presidential candidate, Faye's bid was validated by Senegal's top constitutional body in January, despite his imprisonment.
Unlike Sonko, Faye has not been convicted of any crime which would disqualify him from standing for election.