A police officer in Kansas resigned on Monday after admitting he had fabricated a story that a McDonald’s employee wrote a vulgar insult on his coffee cup.

The Herington Police Department officer, whose name was not made public, claimed that a McDonald’s employee had written “pig,” preceded by an expletive, on a receipt attached to his cup. The department’s police chief, Brian Hornaday, relayed the story on Saturday in a Facebook post that attracted nationwide media attention but has since been deleted.

The tall tale unraveled when McDonald’s provided video footage that proved its employees had not written anything on the cup, Mr. Hornaday said at a news conference on Monday. The 23-year-old officer then admitted he had lied about the supposed incident “as a joke,” Mr. Hornaday said.

“I hope he understands the magnitude of the black eye this gives the law enforcement profession from coast to coast,” he said.