A US police officer was not telling the truth when he claimed McDonald’s had given him a coffee cup with “f****** pig” written on it, according to his force.

Brian Hornaday, the local police chief, said the allegations – which went viral and sparked outrage online – were “completely and solely fabricated”.

When asked to explain the motive behind the incident, the officer who claimed to have received the cup said it was “meant to be a joke”, his chief said.

Mr Hornaday had originally posted an image of the cup on Facebook, saying one of his police officers had received it at a Kansas drive-thru.

The officer should have come forward “prior to damage being done” and “prior to this becoming a nationwide incident”, the Herington police chief told WIBW-TV.

The McDonald’s in Junction City said they had checked security footage and were confident none of their employees had written “f****** pig” on the cup.

It is “absolutely a black eye on law enforcement” and an “obvious violation” of the public’s trust, Mr Hornaday said.

The police chief said his reaction after the initial claims was based on believing that a police officer has integrity.

He said: “It would be foolish of any law enforcement agency or professional to not take the word of their police officer until they can be proven otherwise”.

The 23-year-old officer in question had worked for Herington Police Department for two months and is no longer employed by them after the incident.

Starbucks apologised last month after a police officer was given a coffee cup with "pig" written on the label in Oklahoma.