The former assembly group leader of UKIP, Neil Hamilton, has been blocked from taking a top job in the Senedd’s administration.
In an unprecedented move AMs voted by a majority to stop the former Tatton Tory MP from becoming a commissioner.
Labour AMs and others believed Mr Hamilton was unsuitable because he had not backed a policy aimed at tackling harassment in the legislature.
A total of 31 assembly members voted against the appointment, versus 17 for.
Labour and Plaid Cymru AMs had a free vote but mostly voted against Mr Hamilton – while UKIP and Tory members supported him.
Commissioners oversee different parts of the operation of the assembly and earn more money than ordinary backbench AMs.
There are four and each party group gets to nominate one.
Normally, the selection is a matter for the parties concerned and passes without objections from other AMs.
If Mr Hamilton had been successful in his bid, he would have gained an extra £13,578 on top of his £66,847 basic backbench AMs’ salary, bringing his total pay to £80,425.
He had earned £85,000 a year as group leader until he was replaced by Caroline Jones in May.
Mr Hamilton was nominated by UKIP to replace Ms Jones, who was previously a commissioner.
Before he lost his job as leader Mr Hamilton abstained on an interim assembly policy aimed at tackling inappropriate behaviour. Most assembly members had supported it.
Prior to the vote Cynon Valley Labour AM Vikki Howells said: “The dignity and respect policy is fundamental to how the assembly must operate and I cannot countenance supporting someone who has failed to endorse that policy.”
Mandy Jones, a UKIP member who sits as an independent AM, told the Senedd on Wednesday that she also objected to Mr Hamilton’s nomination because of his abstention.
She said becoming an AM was “not a part time job” and the code of conduct does “not get shrugged off like a wet coat when (it becomes) too uncomfortable”.
“I do not see how his position is compatible with the role of an assembly commissioner,” she said.
Mr Hamilton had promised AMs that he would have served as a commissioner “with the kind of professionalism and honesty and integrity I think I have displayed in the two years I have been here”.
But one source in the Welsh Conservatives thought it was “irregular to try and tell a group who they can and can’t put forward”.
Independent AMs and former Plaid Cymru party members, Neil McEvoy and culture minister Lord Elis-Thomas, were among those who voted for the appointment.
Three AMs – Liberal Democrat education secretary Kirsty Williams, Labour backbencher Mike Hedges and Plaid Cymru’s Bethan Sayed – abstained.