President Rodrigo R. Duterte has pardoned a US marine whom a Philippine court convicted in 2015 for killing a transgender Filipino sex worker in a case that had ignited anti-American sentiment in the former US colony.

Joseph Scott Pemberton, whose release for good conduct was held by prison officials after an appeal by his victim鈥檚 family, had been given the absolute pardon, Foreign Affairs Secretary Teodoro M. Locsin, Jr. tweeted on Monday.

鈥淐utting matters short over what constitutes time served, and since where he was detained was not in the prisoner鈥檚 control 鈥 and to do justice 鈥 the President has granted an absolute pardon to Pemberton,鈥 he said from the presidential palace.

An Olongapo trial court convicted Mr. Pemberton for homicide in 2015, sentencing him to six to 10 years in jail.

Mr. Pemberton could have faced a life sentence had the judge granted prosecutors鈥 request for a murder conviction. The court cited mitigating circumstances, saying Mr. Pemberton was drunk and got confused after discovering that the person he had hired for sex was male.

Jeffrey Laude, a 26-year-old male sex worker who identified as a woman, was found strangled in October 2014 in a motel.

鈥淭hat means Pemberton can go free now,鈥 presidential spokesman Harry L. Roque told GMA News in Filipino, according to a recording of the interview shared by the media network on Viber.

鈥淭he President did not erase Pemberton鈥檚 conviction,鈥 he said. 鈥淗e is still a killer but the President has erased his punishment.鈥

Mr. Duterte said he pardoned the American soldier because he had been treated unfairly.

In a televised speech on Monday night, the President said he had consulted Justice Secretary Menardo I. Guevarra and Executive Secretary Salvador C. Medialdea about the pardon.

The court last week ordered Mr. Pemberton鈥檚 release for good conduct. The Justice department earlier said the American soldier would remain detained pending the appeal of the victim鈥檚 family.

Mr. Guevarra had said the agency would separately appeal Mr. Pemberton鈥檚 release this week. 鈥 Gillian M. Cortez