ROTA, Spain — For President Obama, war is never far from his thoughts. On Sunday afternoon, he flew to this sprawling naval air station near the mouth of the Mediterranean to tour the Ross, one of four guided-missile destroyers that patrol from the Baltic to the Black Sea, potent symbols of America’s military presence in Europe.

“That’s pretty impressive,” Mr. Obama said to Petty Officer Second Class Garrett Nelson, after the sailor told his commander-in-chief about the accuracy of a five-inch, 54-caliber gun mounted on the ship’s foredeck. “That’s better than I do at skeet shooting.”

Mr. Obama’s advisers fought to keep this stop on his five-day trip to Spain and Poland, even after he decided to cut the trip by a day and return home on Sunday to deal with the deadly shootings in Dallas. Sightseeing in Seville, as the president had planned to do, was easy to skip; surveying the military hardware in Rota was not.

Throughout this trip, Mr. Obama has confronted the reality that the United States is engaged in military operations around the world. At a NATO summit meeting in Warsaw, he announced that American troops would lead a battalion stationed in Poland to deter an aggressive Russia. The destroyer in Rota is a pillar of a missile-defense program that Mr. Obama has stuck with despite the tensions it raises with Moscow.