Democratic 2020 presidential hopeful Pete Buttigieg, in an interview that aired Sunday, said President Trump had slandered American troops by considering pardoning servicemen accused of war crimes -- and said the proposal threatened to undermine the country’s “legal and moral” foundations.

“When you serve, you are agreeing to serve the Constitution and uphold the law and, frankly, his idea that being sent to fight makes you automatically into some kind of war criminal is a slander against veterans that could come only from somebody who never served,” the South Bend, Ind., mayor said on ABC News’ “This Week.”

BUTTIGIEG SLAMS TRUMP ON AVOIDING VIETNAM WAR, RIPS BIDEN ON '94 CRIME BILL

Buttigieg, an Afghanistan War veteran, was responding to remarks Trump made Friday in which the president said he was “looking” at possible pardons. The New York Times had first reported Trump was considering granting pardons to soldiers accused of war crimes around Memorial Day.

“Some of these soldiers are people that have fought hard and long,” Trump told reporters. “You know, we teach them how to be great fighters, and then when they fight, sometimes they get really treated very unfairly.”

Trump said he was considering pardons for “two or three of them” but said he hadn’t yet made a decision.

“It’s a little bit controversial. It’s very possible that I’ll let the trials go on, and I’ll make my decision after the trial,” he said.

The Times reported that one of those pardons could go to Navy SEAL Eddie Gallagher, who is accused of war crimes in Iraq. Gallagher is facing premeditated murder and aggravated assault charges stemming from the alleged killing of an injured ISIS prisoner and alleged instances of him intentionally firing sniper rounds at civilians.

Trump intervened in March to have Gallagher moved to less restrictive confinement after a push from Republicans in the House.

But while such pardons may be seen as a pro-troop move, Buttigieg said that “the idea that being sent to war turns you into a murderer is exactly the kind of thing that those of us who have served have been trying to beat back for more than a generation.” He added that such a move would actually remove one of the protections for troops.

“Today, one of the things that protect our troops morally and physically is the knowledge that if anybody in uniform does commit a crime, they will be held accountable by military justice,” he said. “For a president, especially a president who never served, to say he’s going to come in and overrule that system of military justice, undermines the very foundations, legal and moral, of this country.”

A number of veterans groups have also registered their opposition to possible pardons, saying they have not been consulted by the White House about any upcoming pardon or given information about what was being considered.

TRUMP SAYS NAVY SEAL ACCUSED OF WAR CRIMES WILL BE MOVED TO 'LESS RESTRICTIVE CONFINEMENT'

The Times reported that those being considered for pardons include Mathew Golsteyn, a former Army commando charged with murder for killing a suspected Taliban bombmaker in Afghanistan. Trump said in December that he would be “reviewing” the case against Golsteyn, and called him a “U.S. Military hero.”

Buttigieg, who has risen from obscurity to a top-tier candidate in the Democratic primary race in recent months, has made a point of contrasting his own military service to Trump’s lack of service -- and this week accused him of faking a disability to avoid serving in Vietnam.

“This is somebody who, I think it’s fairly obvious to most of us, took advantage of the fact that he was the child of a multimillionaire in order to pretend to be disabled so that somebody could go to war in his place,” Buttigieg said this week in an interview with The Washington Post.

Trump received five deferments from the draft for military service during the Vietnam War. Four were education deferments while he was a college student and the fifth – in 1968 after he graduated – was a medical exemption.

“I have a pretty dim view of his [Trump’s] decision to use his privileged status to fake a disability in order to avoid serving in Vietnam,” he said.

CLICK HERE FOR THE FOX NEWS APP

Asked about the Democratic candidate's comments, the Trump campaign suggested Buttigieg is just trying to grab attention amid recently dipping poll numbers.

“Mayor Pete’s moment in the sun has just about come to an end, so he’ll say anything to try to stay relevant to the radicals in the Democrat Party,” campaign press secretary Kayleigh McEnany said.

Fox News’ Paul Steinhauser and The Associated Press contributed to this report.