WARSAW, Poland (AP) — Poland’s divided parliament on Wednesday endorsed a human rights lawyer as the nation’s next ombudsman, ending months of political tug-of-war over the sensitive position.

In a vote after the ruling right-wing party waived its reservations, the upper house, or Senate, overwhelmingly approved Marcin Wiacek to be the country’s next human rights commissioner – an independent role that the conservative government would like to control.

Earlier this month Wiacek was approved by the lower house, in the chamber’s sixth vote on an issue that for months had driven a wedge between the ruling party and the opposition.

The approval came after the ruling Law and Justice party waved its earlier reservations against Wiacek. Four other candidates had been rejected, one of them twice.

Wiacek, 39, heads the human rights department at Warsaw University. He succeeds Adam Bodnar, who was unpopular with the government for raising issues with it and trying to block some of its decisions.

Bodnar’s term ended last week, as a result of a ruling by a top court, where the government has placed many loyalists.

In his first statement after the Senate’s approval, Wiacek said he is an “independent” person who favors resolving disputes with the European Union.

He said he is in favor of heeding a recent ruling by the European Court of Justice ordering the Polish parliament to stop disciplining judges.