The confidence motion moved by Kumaraswamy was defeated with 99 members voting for the motion and 105 against it in a House of 225 including speaker P R Ramesh Kumar and a nominated member.
The Congress-Janata Dal Secular coalition government in Karnataka headed by chief minister H D Kumaraswamy collapsed on Monday night capping a 14-month long turbulent tenure, losing a vote of confidence in the assembly, setting the stage for the Bharatiya Janata Party's return to power in the southern state.
After losing the trust vote which missed a couple of deadlines, Kumaraswamy, 59, went to Raj Bhavan and submitted his resignation to governor Vajubhai Vala.
The resignation was accepted with immediate effect but Kumaraswamy was asked to continue as caretaker chief minister till alternative arrangements are made.
Bringing to end a three-week long high-voltage intense power struggle triggered by a raft of resignations by rebel lawmakers that made the survival of the government difficult, the confidence motion moved by Kumaraswamy was defeated with 99 members voting for the motion and 105 against it in a House of 225 including speaker P R Ramesh Kumar and a nominated member.
As many as 20 MLAs -- Congress-JDS (17), BSP (1), independents (2) -- skipped the proceedings, reducing the effective strength of the House to 205.
The magic figure for Kumaraswamy to win the trust vote required was 103.
"The motion moved by the chief minister has fallen through," Speaker Kumar announced.
Flashing the victory sign after the voting, BJP leader B S Yeddyurappa, who is hoping to become the chief minister for the fourth time, described the outcome as a "victory for democracy" as people were fed up with the Kumaraswamy government.
After the assembly polls last year, Yeddyurappa resigned without facing the trust vote since he did not have the numbers on his side with the BJP, which bagged 104 seats, falling short of majority by nine seats.
He assured the people of Karnataka that "an era of development" would start with the BJP in power.
On the next step, Yeddyurappa, 76, said an appropriate decision would be taken "as early as possible."
The BJP dubbed the fall of the government as a "Game of Karma".
Kumaraswamy, son of former prime minister H D Deve Gowda, watched the proceedings sitting in a pensive mood after a spirited reply to the debate.
With rebellion exploding in its face, the coalition government was hanging by a thread for the last three weeks with the Supreme Court verdict that rebel law makers ought not to be compelled to attend the session tipping the scales in favour of the BJP.
Outwitted in the numbers game and defeat staring in his face with the rebel MLAs in no mood to step back from their position not to attend the assembly session, Kumaraswamy gave indications of quitting in the initial remarks while winding up the debate on the confidence motion.
"I am ready to happily sacrifice this position," he said appearing resigned to the fate of his ministry, as the assembly debated the confidence motion for four days.
In his reply, Kumaraswamy said discussions were on why he had not resigned and was sticking to the chair.
Sounding philosophical, he said when the 2018 assembly polls results were out, he had plans to quit politics.
"My political entry itself was all of a sudden and unexpected".
Kumaraswamy lashed out at the BJP for repeatedly trying to topple his government and told the saffron party that its government would not last long and in the event of collapse, it is better to go for elections.
"First bomb will explode in ministry formation," he said.
Asserting that his government was not shameless, he asked, "what wrong have we committed. We tried to create history.
"We have worked honestly to provide people friendly government."
Accusing the BJP of being in a hurry, he said, "I am not going to run away after speech. Let the people of the state know why I was removed. I am not going to run away fearing numbers. Let the votes be counted.
"Chief Minister's seat is not permanent to anyone."
The BJP did not take part in the debate except for interventions and remained silent despite allegations thrown at it by the Congress and JD-S members.
In his speech, Congress leader Siddaramaiah accused the BJP of trying to come to power through backdoor using bribery and "wholesale" trade of MLAs.
He said the 15 MLAs resigning was nothing but "wholesale trade."
Siddaramaiah, a former chief minister, alleged that "Rs 20,25 and 30 crore" were offered to lure the MLAs and asked "Where did this money come from?"
The 15 rebel MLAs of the Congress and the JD-S have sought four weeks' time to appear before Speaker Kumar in connection with the plea for their disqualification from the state assembly.
The speaker is also yet to take a decision on the resignations.
"Yes, we have sought four weeks' time from the speaker. We have approached the speaker through our advocate," Hunsur JD-S MLA A H Vishwanath said.
The government had ignored two deadlines set by governor Vala, who had asked Kumaraswamy to prove his majority on Friday itself, saying he had "prima facie satisfaction" that it has lost its majority confidence of the house.
The tumoil reached a climax after dramatic twists and turns that saw the MLAs of rival camps being corralled in resorts and hotels, allegations of bribery, rebel lawmakers knock the doors of the Supreme Court to decide on the issues of whip, floor test and governor's intervention.
Kumaraswamy and the Congress moved the Supreme Court accusing the Governor of interfering with the Assembly proceedings when the debate on the trust vote was underway and sought clarification on its July 17 order causing hindrance in issuing whip to the legislators.
The court had held that the MLAs cannot be compelled to participate in the assembly proceedings.
The ruling coalition made frenetic efforts to win back the rebels with the chief minister making a desperate appeal to them on Sunday to attend the session to save his ministry but they refused to budge, sealing the fate of his government.
As many as 16 MLAs -- 13 from the Congress and three from JD-S -- had resigned, while independent MLAs R Shankar and H Nagesh had withdrawn their support to the coalition government, pushing it to the precipice.
One Congress member Ramalinga Reddy retracted from his decision to resign, saying he would support the government.
This is the third motion on trust vote after the 2018 assembly polls yielded a fractured mandate with the BJP emerging as the single largest party with 104 seats, but failing to mobilise the numbers.
The BJP added one more to its tally after the victory of an MLA in a by-election.
Yeddyurappa had resigned as CM after being in office for three days before facing the trust vote in May last year.
Kumaraswamy, who succeeded him, had won the trust vote after forming the coalition government with the Congress.
Fighting the battle for survival, the ruling coalition used all ammunition to tame the rebels from making offers to holding out the threat of disqualification but all in vain.
The Congress and JD-S had also sought disqualification of its rebel legislators accusing the BJP of using money power to lure its members.