Within hours of the rampage in Barcelona on Thursday, President Trump urged those who seek to combat terrorism to “study what General Pershing of the United States did to terrorists when caught.”

“There was no more Radical Islamic Terror for 35 years!” he added in his Twitter post.

The White House did not respond to a request to clarify what should be studied. However, Mr. Trump has previously referred to a long-debunked fable about how Gen. John J. “Black Jack” Pershing crushed a rebellion in the predominantly Muslim Moro Province of the Philippines after the Spanish-American War.

During a February 2016 campaign stop in South Carolina, Mr. Trump claimed that Pershing captured “50 terrorists” and shot all but one with bullets smeared in pig’s blood.

The survivor was ordered to spread the tale of the episode, Mr. Trump said, “And for 25 years, there wasn’t a problem.” (Mr. Trump’s tweet on Thursday added 10 years to this alleged peace.)