Media playback is unsupported on your device Media caption Damian Green speaking to reporters outside his home in his constituency of Ashford

David Davis has warned Downing Street not to sack Damian Green as a result of a "wrongful attempt by former officers to do him down", sources close to the Brexit Secretary have told the BBC.

One said Mr Davis might be willing to resign over the issue, although another stressed no threat had been made.

It comes after a retired detective said "thousands" of legal porn images had been found on Mr Green's computer.

Mr Green says he never watched or downloaded pornography on the computer.

Mr Davis has thrown a "protective cloak" around the First Secretary of State, who is effectively Theresa May's second-in-command, a source told the BBC, after the story was reported in the London Evening Standard.

The Brexit Secretary feels he "has a dog in the fight" because Mr Green was his subordinate on the Conservative shadow home affairs team in 2008 when the material was allegedly discovered on Mr Green's computer, the BBC's deputy political editor John Pienaar said.

According to one source, Mr Davis might be prepared to contemplate resignation, if he felt Mr Green had been "mistreated".

Media playback is unsupported on your device Media caption "I was shocked": Former detective constable Neil Lewis speaks to the BBC

Another close associate said no threat of resignation had been made but the Brexit's secretary's strong feeling had been conveyed to Downing Street "at the highest level".

It was made clear that the warning from Mr Davis did not apply to the possibility of Mr Green losing his job under any circumstances, says John Pienaar.

"It's right that allegations of misconduct towards individuals are properly investigated," said an associate of Mr Davis.

"But police officers have a duty of confidentiality which should be upheld".

'Police state'

Retired Scotland Yard detective Neil Lewis told BBC News "thousands" of thumbnail images of legal pornography had been found on Mr Green's computer during a 2008 inquiry into government leaks.

The BBC understands a Cabinet Office report into Mr Green's conduct - which ranges wider than allegations of viewing pornography on an office computer, and covers accusations of inappropriate conduct - could land on the prime minister's desk next week.

The investigation has been carried out by senior Cabinet Office official Sue Gray.

Speaking on the BBC's Newsnight programme, former Attorney General Dominic Grieve said the police officers were "in flagrant breach of their own code of conduct".

"If you think something's relevant, you do it by a proper official means, you do not go freelancing, as these two officers have done, and it has the smack of the police state about it," he said.

"I find it very worrying. They are not and must not be allowed to abuse those powers."

But former Gloucestershire Chief Constable Tim Brain defended the actions of the officers saying they had come forward with what they considered to be "relevant information" to an ongoing inquiry.

"Let's just think about this as a workplace computer and to think whether we are happy that people, our MPs, can have this kind of material on what is an official computer," he said.

What is the row all about?

The allegations date back to November 2008 when the Conservatives were in opposition and Damian Green was their immigration spokesman

He embarrassed the Labour government with a series of leaks about illegal immigration and other issues

Police raided his Parliamentary office as part of an inquiry into how he got his hands on confidential documents

His office computer was seized and he was detained for nine hours - sparking fury among Tory MPs

No charges were brought against the MP or civil servant Christopher Galley, who passed unauthorised material to Mr Green, although the official was sacked

The officer in charge of the inquiry, Bob Quick - widely criticised by Tory MPs for the raid - resigned six months later over an alleged security breach

But a month ago, Mr Quick disclosed that pornographic material had been found on the seized computer, adding that the police had not pursued the matter at the time or told Mr Green about it

The matter has since been investigated by the Cabinet Office as part on a wider inquiry into claims of inappropriate behaviour by Mr Green towards journalist Kate Maltby

The chairman of the Commons culture committee said Mr Lewis should not give media interviews as the public was not getting the "whole picture".

Tory MP Damian Collins told BBC Radio 4's Any Questions the "Cabinet Office is running that investigation. They should receive and see any evidence that's pertinent to it... We should wait to see what the result of the official investigation is."

The DUP's leader at Westminster, Nigel Dodds, told Any Questions "police are not above the law and it is totally wrong that an individual police officer should go out and make public statements like this".

Conservative MP Andrew Mitchell also defended Mr Green on BBC Radio 4's Today programme, saying: "It is the misuse of entirely legal information to blacken the name of a serving cabinet minister."

But Mr Lewis said a check of the computer's internet history over a three-month period showed pornography had been viewed "extensively" and a number of factors meant that he was sure it was Mr Green, the MP for Ashford, Kent, who was accessing the material.

Media playback is unsupported on your device Media caption Jacob Rees-Mogg tells Amol Rajan police "behaved disgracefully" by raiding Damian Green's office in 2008

Asked about the allegations in his constituency on Friday morning, Mr Green said: "I have maintained all along - I still maintain, it is the truth, that I didn't download or look at pornography on my computer but obviously while the investigation is going on, I can't say any more than that."

On Tuesday, Scotland Yard confirmed its department for professional standards was examining allegations that Mr Lewis had disclosed confidential information.

A statement from the Metropolitan Police said: "Confidential information gathered during a police inquiry should not be made public."

The Cabinet Office investigation into Mr Green was prompted by allegations of inappropriate behaviour in 2015 and 2016 made by Conservative activist Kate Maltby, which the MP has described as "completely false".

The inquiry is believed to centre on the ministerial code, which sets out the standards of conduct expected of government ministers.