A detective inspector in the Devon and Cornwall police force has resigned after being found with a Class A drug.
The 40-year-old officer was arrested in Torquay in July after door staff of a bar detained him in the toilets.
The Independent Police Complaints Commission (IPCC), which investigated, said he was not prosecuted.
The Crown Prosecution Service (CPS) said the amount of the drug was "extremely small and was consistent with personal use".
Police were called to the Green Ginger bar in Fleet Walk just before midnight on 10 July.
Door staff said a man had been found in a toilet cubicle with another man and that there was an indication drugs had been taken in the cubicle.
One of the men told officers he was a policeman.
The other man was also arrested and has since been released without any further action.
The force's professional standards department submitted evidence to the CPS.
It decided not to prosecute as the quantity of drug in the officer's possession was extremely small and was consistent with personal use.
IPCC Commissioner Rebecca Marsh said: "Following the CPS decision that this officer be given a caution following his admission of possessing Class A drugs he has now resigned from the police service.
"In cases of possession of such a small quantity of drugs a caution is usually the outcome."
She said that accepting the resignation would save money by ending the internal misconduct procedure.
"The public expect the highest level of integrity from police officers and this man has lost his career," she said.
Det Ch Insp Jim Colwell of Devon and Cornwall Police said the force had carried out a full internal investigation.
He said: "This has led to the resignation of the officer concerned at the end of November with immediate effect.
"As he has accepted a criminal caution and is no longer part of the organisation, it is effectively an end to the matter."