Image caption Alun Cairns (R) sent Andrew RT Davies (L) a text informing him of an attempt to oust him

The text that accidentally tipped off Andrew RT Davies about an attempt to oust him was sent by Welsh Secretary Alun Cairns.

Mr Davies revealed the text after his resignation as Tory assembly leader.

Sources confirmed that Mr Cairns sent the message, which discussed how and when to remove Mr Davies as leader, last spring.

The minister's spokesman said Mr Cairns had a productive working relationship with the former leader.

The text was intended for other senior Welsh Conservatives in Westminster - and not for the South Wales Central AM.

Shortly after stepping down, Mr Davies said he was copied into the text message by mistake fourteen months ago, but declined to say who sent it.

"I think the tone of the text said about 'keeping a lid on it' or 'removing him straight away' - and that was from the other end of the M4," he said at the time.

BBC Wales understands the message was sent following the defection of Mark Reckless from UKIP, last April.

Tory MPs were angry that Mr Davies had welcomed Mr Reckless into the Tory group in Cardiff Bay, although he has not re-joined the party.

In a statement, a spokesman for Mr Cairns said: "Alun Cairns has a very productive working relationship with Mr Davies, in particular on local issues over many years.

"Communication during election periods on topical issues take various forms and shouldn't be taken in isolation.

"Alun spoke with Andrew regularly, aside from any particular messages about Mark Reckless, to clear up any potential misunderstanding and the wider campaign.

"As this was almost a year and a half ago and the matter has not been raised since, it was considered closed."