A little-known politician beat the ruling Pakistan Muslim League-Nawaz (PML-N) to become chairman of the Senate on Monday, in a vote the PML-N said was a stitch up by opposition parties.

Sadiq Sanjrani, a senator from a remote part of the southwestern Balochistan province, was a compromise candidate backed by opposition parties in a rare show of unity.

PML-N officials, who allege elements of the military are trying to weaken their party, accuse Sanjrani of being a “pro-establishment” candidate. Sanjrani denies being a military stooge and the Army has rejected claims of meddling.

Sanjrani won 57 votes in the 104-seat chamber to beat PML-N candidate Raja Zafarul’s 46, according to presiding officer Sardar Yaqoob Nasir.

“The face of this house is blackened today,” said Mir Hasil Bizenjo, a government minister and ally of former prime minister Nawaz Sharif who was ousted by a Supreme Court ruling last July that his party suggested was influenced by the powerful military.

The military, which has ruled Pakistan for nearly half of the time since independence from British colonial rule in 1947, denies interfering in the judicial process.

“I appeal to the institutions, I appeal to the political parties that for God’s sake let this country take its right course. Let this country take its democratic path,” Bizenjo told the Senate.

PML-N displaced the Pakistan Peoples Party (PPP) as the single biggest one in the upper house in elections on March 3. But the secret ballot of members of the four provincial assemblies and the federal parliament was marred by allegations of horse trading and seat buying.

The PPP has a long history of battling military dictatorships under the leadership of Zardari’s slain wife Benazir Bhutto and her late father Zulfikar Ali Bhutto and it has denied cutting a deal with the military.

The Pakistan Tehreek-e-Insaf (PTI) party which joined the PPP in backing the new Senate chief, has also rejected claims of military involvement, with party leader Imran Khan tweeting that Sanjrani’s election would “strengthen the federation”.

“We are happy for the people of Balochistan and for the federation of Pakistan,” Khan tweeted.

In a lighter moment, all senators clapped and banged tables in appreciation when a new member, from a marginalised Hindu caste, entered the chamber.

Krishna Kumari’s election was seen as a breakthrough for her Dalit community, who are the lowest rung on the caste ladder and are often referred to as the “Untouchables”.

Pakistan is due to hold a general election in mid-2018.