BANGALORE - The chief minister of a key Indian state plunged into a political crisis that saw Supreme Court hearings and accusations of bribery quit Saturday after admitting he did not have enough support to form a government.

BS Yeddyurappa of the Hindu nationalist Bharatiya Janata Party (BJP) stepped down after just two days in the post and minutes before he was to have faced a vote of confidence in the Karnataka state assembly.

His move ended a week of mounting acrimony between Prime Minister Narendra Modi’s BJP and the opposition Congress party. Congress, which had ruled the southern state until an election last week, will now get a new chance to form a government with a regional ally. The battle could set the tone for a national election to be held next year.

The BJP deposed Congress as the biggest party after the Karnataka election last Saturday. But its 104 seats were not enough for a majority in the 224-member assembly. Congress saw its numbers slashed from 122 to 78 seats but it formed a coalition with the regional Janata Dal (secular) which finished with 37 seats.

“The mandate was not for Congress and Janata Dal. They lost the election but they indulged in opportunist politics,” Yeddyurappa told the assembly. “I have faced the test of fire all my life. I will lose nothing if I lose power. I am going straight to the governor’s house to give my resignation,” the 75-year-old said. Opposition lawmakers cheered and flashed V for victory signs as Yeddyurappa left the assembly followed by his supporters.

The buildup to the resignation saw accusations of bribery and poaching made against the BJP after the state governor asked Yeddyurappa to try to form an administration even though he did not have a majority.

Congress went to the Supreme Court to try to prevent the BJP from forming a government in the prosperous state, home to the IT hub of Bangalore.

The court ruled Thursday that Yeddyurappa should be allowed to take an oath of office. But a day later it said Yeddyurappa must pass a vote of confidence to prove his majority on Saturday.

India’s top court met a third time Saturday to reject a move by Congress to stop Yeddyurappa appointing a speaker of his choice.

Congress and its ally accused the BJP of offering up to $15 million to their members to switch sides in the vote. Modi’s party strongly denied the allegation.

Congress and Janata Dal even moved their lawmakers to luxury hotels outside the state to make sure they were not tempted to switch sides ahead of the vote.

Reports said their mobile phones had been confiscated so they could not be contacted by rivals. Congress president Rahul Gandhi repeated the corruption charges Saturday and accused Modi of personally approving the offering of bribes. “You’ve seen openly how the PM directly authorised purchasing of (lawmakers) in Karnataka, so the idea that PM spreads in the country that he is fighting corruption is a blatant lie,” Gandhi said.

Congress has been desperate to cling on to Karnataka, its last major bastion. It has lost 12 state elections since the BJP took national power in 2014.