In the end, the fracturing of the reformist camp and disgust with Mr. Rouhani, who could only watch as President Donald J. Trump withdrew from the nuclear deal and reimposed sanctions in 2018, resulted in a weak showing for moderates. The Interior Ministry said Mr. Hemmati came in third with around 2.4 million votes, after the second-place finisher, Mohsen Rezaee, a former commander in chief of powerful Revolutionary Guards Corps, who won around 3.4 million votes.