A police officer accused of taking £2,000 in cash and ignoring evidence in a drugs raid told a court he was in a panic over the safety of his family.
Pc Anthony Davitt was caught with the cash in his trousers after the operation, which was set up by his force's internal investigations branch.
He told Liverpool Crown Court he panicked when he realised he knew the man whose house he was raiding.
Pc Davitt, of West Derby, denies misconduct in a public office.
The 38-year-old was ordered to lead the search of the home of a suspected drug dealer in Fazakerley, Liverpool, in September 2009.
Davitt, of Whinmoor Road, told the court he had seen the suspect in the company of "known gangsters" in a local gym which he had used.
He said: "I started to panic because I knew him. It would not be hard for him to find out where I lived."
"There are lads who train in that gym who have a criminal background. I would not want to cross them in the area where my family live," he said.
The suspect at the house was an undercover officer who was wearing a hidden microphone which was recording their conversation.
Pc Davitt told the court the man told him he had seen him in the area walking his dog with his son and he took that as a threat.
However, Mark Ainsworth, for the prosecution, said this was not caught by the microphone.
He read from a transcript of their conversation in which the undercover officer can be heard telling Pc Davitt that the cash was in the kitchen.
He said Pc Davitt was whispering so the other officers on the raid could not hear the conversation he was having.
Pc Davitt was heard saying: "Say nothing. If they don't find it, they don't find it."
He is later heard saying: "I will try something, all right."
The undercover officer is then heard saying: "I will sort you out."
Pc Davitt told the jury he believed that was another threat. He said he then put £2,000 in cash which he found in the kitchen in his pocket because he wanted to get back to the station with it as evidence and report what had happened to a senior officer.
He said he had believed he and his family would be put in danger if he had arrested the man, cautioned him or if he told any of his fellow officers who were on the raid with him about what he had found.
The court has previously heard how police hid £2,000 in cash in the kitchen and a further £1,000 in cash in the living room.
They had also hidden a quantity of white powder wrapped in cling film in a tube of Pringles crisps in the kitchen.
An amount of Mannitol, an additive which is often mixed into drugs, and a banknote scanning device were also hidden in the house by police, but Pc Davitt had not reported any of these things and was later found with the cash on his person.
The case continues.