Forced out of office over corruption charges, BS Yeddyurappa got his way Wednesday when a loyalist, DV Sadananda Gowda, was chosen to replace him as the Karnataka chief minister.
Gowda was elected soon after governor HR Bhardwaj gave the go-ahead for Yeddyurappa's prosecution.
A secret ballot was called to choose the BJP legislature party leader after the central leaders' efforts to find a consensus candidate failed.
Gowda, expected to serve out the remaining 22 months of the BJP's first government in the south, got 65 votes.
His challenger, rural development minister Jagadish Shettar - propped up by the rival camp led by party general secretary HN Ananth Kumar - fell short by 12 votes.
The party didn't officially declare the vote share. Gowda, 58, will be sworn in at 4.30pm on Thursday. Shettar may be named his deputy.
Yeddyurappa, who belongs to the politically significant Lingayat community, backed Gowda, a Vokkalinga, eyeing a comeback, confident of getting the all-clear from the court in the mining scandal.
Kumar sought to rally Lingayat MLAs in support of Shettar, who is one of them, to check what he said was an attempt by Yeddyurappa to rule by "proxy".
Leader of opposition in the Rajya Sabha Arun Jaitley and senior party leader Rajnath Singh, deputed to oversee the election of the new CM, went for the secret ballot after they failed to bridge the factional divide.
Gowda, in his second term as the Udupi-Chikmagalur member of Parliament, served as the state BJP chief from 2007-2010.
Gowda, also a two-time MLA, pledged a "pro-development, pro-infrastructure, people-friendly" government. Shettar said he had accepted the verdict and would work with Gowda.
Of the 122 party MLAs in the 224-member House, 118 participated in the vote.
Yeddyurappa handed his resignation to Bhardwaj on July 31 after the party asked him to step down following his indictment by the anti-corruption watchdog in the scam.
Lokayukta Santosh Hegde, who retired on August 2, has pegged the loss to exchequer at Rs 16,085 crore.