A controversial UKIP member of the Welsh assembly has won a three-way battle to lead the party in the Senedd.
Gareth Bennett has blamed immigrants for rubbish in Cardiff, and claimed transgender people undermined society by their “deviation from the norm”.
He becomes the fourth leader of UKIP in Wales since the 2016 assembly election.
Runner up Neil Hamilton said he could “happily” work with Mr Bennett, but outgoing leader Caroline Jones said she had “a lot of thinking to do”.
UKIP leader Gerard Batten said he now expected his Welsh assembly members to “work together for UKIP’s cause and get on with the job.”
Mr Bennett, AM for South Wales Central, beat former Tory MP Mr Hamilton by 269 to 193 votes in the second round of counting.
Ms Jones – leader for just six weeks – was eliminated in the first round with 130 votes.
UKIP ordered the ballot of nearly 900 members in Wales to settle a row sparked when Ms Jones ousted Mr Hamilton as group leader in May.
The result was announced by party chairman Tony McIntyre at UKIP headquarters in Newton Abbot, Devon, shortly after the votes were counted there on Friday.
Mr Batten said: “I wish to extend my congratulations to Gareth Bennett.
“I now expect all elected members in Wales to work together for UKIP’s cause and to get on with the job.”
Mr Bennett – who has vowed to campaign to abolish the Welsh assembly – said: “I’m delighted to have won the support of the party members in Wales to take UKIP forward into the next assembly term.
“I had stated that this election must be fought on policies, because UKIP has to stand for something radical and it has to stand for something other than Brexit.
“I look forward to working with the other members of the UKIP Group in the Welsh assembly to challenge the Cardiff Bay establishment and provide a real alternative for Wales in the next round of assembly elections in 2021.”
Defeated candidate Ms Jones congratulated Mr Bennett on his victory, although she said the party’s decision to hold an election six weeks after she became leader “doesn’t leave a good taste in my mouth”.
She said she bore no “malice” to Mr Bennett and did not see why not she could not serve as an AM under him.
But she added: “I am concerned about my future now. I’ve got a lot of thinking to do.
“I don’t know where a woman’s place is in my party.
“I don’t know what my future holds”.
Mr Hamilton “warmly congratulated” Mr Bennett, saying on Twitter: “He is a good friend of mine and I can work happily with him.
“For many UKIP members, the election was a referendum on the Assembly’s very existence. Clearly, we must all learn from this.”
Reaction from other parties was more scathing.
Welsh Labour’s Health Secretary Vaughan Gething described Mr Bennett as a “deeply offensive man but not amusing in the slightest”, while fellow Labour AM Lee Waters said: “Game over for UKIP in the Assembly? I can’t see several of their AMs staying the group with Gareth Bennett as their leader.”
Plaid Cymru leader Leanne Wood said she had been “consistent in my criticism of UKIP as a party that cannot and will not represent the values of Wales”, adding that she thought their demise would be “welcomed”.
With 876 UKIP members in Wales eligible to vote, 514 did so resulting in a turnout of 58.7%.
Gareth Bennett becomes UKIP’s fourth leader in Wales since Nathan Gill – appointed by Nigel Farage in 2014 – led the campaign which saw UKIP win its first seven Senedd seats at the 2016 assembly election.
The group, which has been rocked by rows, had since shrunk to just five, with the departure of Mr Gill – who sat as an independent before quitting the assembly – and of Mark Reckless, who now sits with the Conservatives.