Media playback is unsupported on your device Media caption A former Tory MP aims to be the first leader of UKIP's AMs in the Welsh Assembly.

UKIP leader Nigel Farage has attacked the decision to elect ex-Tory MP Neil Hamilton as leader of the party's new group in the Welsh Assembly.

Mr Farage called UKIP AMs' choice of Mr Hamilton over Nathan Gill on Tuesday an "unjust" act of "deep ingratitude".

Mr Hamilton responded: "We in Wales will give appropriate weight to the opinion of the MEP for the South East of England."

Mr Gill remains leader of UKIP Wales, a position appointed by Mr Farage.

Mr Gill told BBC Wales the defeat was "slightly bizarre".

He was backed by three UKIP AMs while four supported Mr Hamilton.

Before the meeting both sides had claimed to have the numbers to win.

'Maximum impact'

UKIP assembly group leader Neil Hamilton confirmed his victory at an impromptu news conference in an assembly corridor.

"We've achieved an outcome by consensus," he said.

"We decided to put all past differences behind us and forget the lead up to the election campaign, where there was a lot of personal animosity created.

"I've been chosen to do a specific job to be leader of the UKIP AMs within the assembly.

"I've got a great deal of parliamentary experience. I've been a government minister.

"I'm going to make use of that experience within the group to give UKIP the maximum amount of impact during the course of the next five years."

Mr Hamilton's salary will be £84,000 as leader of the UKIP assembly group.

This consists of an AM's salary of £64,000, plus an additional payment for being leader of an opposition group.

The additional payment is £13,000 plus £1,000 for every member - UKIP has seven AMs, giving a total of £20,000 in additional payments.

Image caption Nathan Gill was sworn in as an AM on Saturday

But Mr Farage said Mr Hamilton's victory made UKIP appear "too like the other parties that we have fought so hard against".

"I have worked closely with Nathan Gill as leader of UKIP Wales," he said.

"I have always found him to be hard-working, honest, and loyal.

"His removal after a successful Welsh Assembly election campaign is unjust and an act of deep ingratitude.

Media playback is unsupported on your device Media caption Neil Hamilton says UKIP leader Nigel Farage is just 'throwing his toys out of the pram' after the former Tory MP was elected the party's leader in the assembly

Mr Hamilton said Mr Farage was "throwing his toys out of the pram".

Mr Gill told BBC Wales the day's events were "slightly bizarre".

"I guess only UKIP can do this kind of thing, replace somebody whose taken us to our greatest victory in domestic politics and then the AMs that got there, over half of them, four of the seven, decided to replace me as leader."

"Obviously it doesn't feel brilliantly. But let's face it, we've got a job to do.

"As far I'm concerned that job is on the 23rd of June for us to vote to leave the EU. That will now become my focus."

Mr Gill said Mr Hamilton's position as leader of the group of AMs did not "technically" make him leader of the party in Wales.

"I wouldn't need to insist that. That is the reality of the position."

Image caption All smiles: UKIP AMs Mark Reckless, Nathan Gill and Neil Hamilton at the Senedd on Saturday

Mr Gill has previously said he would step down as an MEP if he was elected to the assembly, but BBC Wales understands he may now be reconsidering that decision.

He told an election debate in April that he probably would not have chosen Mr Hamilton as a UKIP candidate.

That led Mr Hamilton's wife, Christine, to call the UKIP Wales leader a "third-rate general".

UKIP won its first ever AMs in the 5 May assembly election, claiming seven seats.

Some of those involved in UKIP's election campaign had expected to get jobs in the assembly group after the party won its first ever AMs in the 5 May election.

But their hopes were dashed after the election of Neil Hamilton.

Two of those who believe they were "sacked" were Llyr Powell, a voluntary political advisor, and Sam Gould, campaign manager.

Asked what happened at Tuesday's meeting, Llyr Powell called it "an upset" before adding that it was "a personality cult possibly towards Neil Hamilton".

Labour AM Mark Drakeford, health minister in the previous assembly, said: "I've heard UKIP say that the assembly won't be the same - it certainly won't be.

"Having to deal with them is not something I will look forward to."

Analysis by Daniel Davies, BBC Wales political correspondent

One party has a disappointing election result, losing three seats. Another has a breakthrough, winning seven seats.

And yet it is the latter - UKIP - that has gone through the upheaval of a bitter leadership contest.

Welsh Conservative leader Andrew RT Davies apparently enjoys the full support of the Tories.

Meanwhile, UKIP's Welsh leader Nathan Gill - Nigel Farage's man in Wales - has been rejected by fellow AMs in favour of Neil Hamilton.

Mr Hamilton says they have put their differences behind them.

Judging by the mood of some in the party, I would say that is unlikely.

Observers - from all parties and none - do not know quite what to make of the spectacle.

Here is the verdict of one long-serving assembly employee: "They'll liven the place up."