Tehran mayor Mohammad Baqer Qalibaf quit Iran's presidential race on Monday and said he would back hardline cleric Ebrahim Raisi in Friday's vote.
Qalibaf, a former Revolutionary Guards commander and police chief, was one of the main conservative challengers to President Hassan Rouhani, who is seeking a second term.
"I should take an important decision to keep the unity of revolutionary forces," Qalibaf said in a statement published in state media. "I ask all my supporters around the country to use all their capacity to help my brother, Mr Ebrahim Raisi, win the election."
Raisi's popularity has rise steadily in recent weeks and Qalibaf's decision should give him a last-minute boost against Rouhani, a pragmatist who has eased Iran's international isolation but failed to spur a sluggish economy.
Qalibaf's allies had argued that he had more recognition in the capital Tehran and among young voters, and offered a more coherent economic plan than some other conservative candidates.
He was left with no option but to quit the race, however, when main conservative parties and clerical bodies threw their support behind Raisi, a jurist and cleric who studied at the feet of Supreme Leader Ayatollah Ali Khamenei.
The news Qalibaf was standing down broke as Raisi was delivering a speech in Shiraz, causing delight among his supporters. The crowd started chanting "Qalibaf, Thank you!" according to videos released on social media.
"I am also very thankful," Raisi replied to the crowd. "He did a revolutionary act."
Qalibaf finished second in the last election four years ago with 16.5 percent of the vote. Rouhani won just over 50 percent, averting a second round.
Some conservatives had been unhappy that Qalibaf was standing again and risking a split in the anti-Rouhani vote.
"The biggest fear of the conservatives was that Qalibaf may outperform Raisi on Friday, but not be able to pose a serious challenge, let alone beat Rouhani in the run-off," said Hossein Rassam, a former adviser to Britain's Foreign Office.
Rouhani has warned his supporters that Qalibaf and Raisi, whose backgrounds are in the Revolutionary Guards and Iran's hardline judiciary, will take the country back to "extremism."
He said on Monday he needed a stronger mandate to liberalise Iranian society.
Hamid Aboutalebi, Rouhani's deputy chief of staff, said in a tweet that most of Qalibaf's supporters would now vote for Rouhani as only those two candidates had managerial experience and a solid plan.
"Qalibaf’s votes will be divided between Rouhani and Raisi. In Tehran, his votes will go mainly to Rouhani but outside Tehran his supporters will vote for Raisi," said political analyst Hamid Farahvashian.
"However, I don't think there will be a significant impact as Qalibaf got six million votes in 2013."
Only minutes after the news, posters appeared on conservative media showing the black-turbaned Raisi alongside Qalibaf, wearing a yellow safety helmet.
Analysts have said Raisi might name Qalibaf as his vice-president to appeal to technocrats, although neither of them has responded to such predictions.
Raisi and Qalibaf will appear together at a rally in Tehran on Tuesday.
The two had adopted similar campaign tactics, criticising Rouhani's economic record -- particularly high unemployment, which rose 1.4 percent last year to 12.4 percent -- and his policy of detente with the West.
Both had promised to create five to six million jobs in their first terms, if elected, and to triple monthly cash handouts to Iran's poor, but have been criticised for not explaining how they would fund such programmes.
"Raisi may not have a very strong vote block, but as some polls have suggested, his negative vote is smaller than Qalibaf's," said Hossein Rassam. "It is not just about the popularity ... of a candidate, but (their) unpopularity too."