President Trump resurrected what historians believe is an urban legend about Gen. John Pershing executing dozens of Muslim prisoners with bullets dipped in pigs' blood, telling people to read up on the history after a terror attack in Barcelona, Spain, left more than a dozen people dead Thursday.

"Study what General Pershing of the United States did to terrorists when caught. There was no more Radical Islamic Terror for 35 years!" Trump tweeted after he condemned the attack and told Spain to be "tough and strong."

Trump first told the story about Pershing killing Muslim prisoners in the Philippines in the early 20th century while the presidential candidate was at a rally in Charleston, S.C., in February 2016.

"He took 50 bullets and he dipped them in pig's blood," Trump said. "And he had his men load his rifles and he lined up the 50 people, and they shot 49 of those people. And the 50th person, he said, ‘You go back to your people and you tell them what happened.' And for 25 years there wasn't a problem."

Urban legend website called the story "false" and fact-checking website Politifact rated the tale "pants on fire."

However, there are historical accounts of U.S. soldiers burying pigs alongside dead Muslim fighters in the Philippinnes' Moro Province.

The tactic was supposedly used to scare Islamic insurgents known as "juramentados" into halting their attacks. To Muslims, pigs are unholy and the insurgents feared that if they died, Pershing's practice would deny them entry into heaven.

The story is highly controversial because it suggests that the government has used a deliberate form of religious discrimination as a successful anti-terror tactic. A 2009 biography of Pershing by Jim Lacey, a military analyst for the Institute for Defense Analyses, claimed to confirm that Pershing did use the tactic.

"Until now the historical verdict is that this was a vicious rumor and while it may have happened in occasion, Pershing neither knew about it nor, given his humane outlook, would have condoned such an action. That verdict is wrong as Pershing's own unpublished autobiography states," Lacey wrote in Pershing: A Biography, published by PalGrave MacMillan.

The book then cites an unpublished letter by Pershing, stating: "These juramentado attacks were materially reduced in number by a practice the Army had already adopted, one that the Mohammedans held in abhorrence: The bodies were publicly buried in the same grave with a dead pig. It was not pleasant to have to take such measures but the prospect of going to hell instead of heaven sometimes deterred the would-be assassins."

In a 2010 interview, Lacey said he discovered Pershing's unpublished autobiography while looking through the general's papers.

• Sean Higgins contributed to this report.