A Texas police officer has been fired after allegedly giving a homeless man a sandwich filled with faeces.

Matthew Luckhurt had been a member of the police force in San Antonio for five years before he was dismissed following an internal investigation into the incident, which reportedly took place in July.

Luckhurt reportedly told a fellow officer about the sandwich, which was reported to authorities after his colleagues said they were 'disgusted' by the rumour, NBC News reported.

The police officer allegedly told at least one other member of staff that he had picked up faeces from the ground, put it with bread and put it in a container to give to a homeless man.

"Firing this officer was the right thing to do," San Antonio Mayor Ivy Taylor said in a statement reported by the news service.

"His actions were a betrayal of every value we have in our community, and he is not representative of our great police force."

However, a lawyer for Luckhurt reportedly said the officer had joked with colleagues about giving the homeless man a sandwich filled with faeces, but had not done so.

But an internal investigation determined the officer had tried to give a homeless man the sandwich, in what Police Chief William McManus told the Associated Press was "a vile and disgusting act".

The incident had allegedly been reported to police supervisors by at least two members of staff.

City councillor Joe Krier told the News-Express: "We have very few bad apples in a barrel full of outstanding police and fire. But it's our job to get the bad apples out of the barrel as quickly as possible when they do bad things."