When President Trump gave a speech to a group of sheriffs in Tampa late last month, his decision to travel forced a large contingent of Secret Service agents to head to a state that was then battling one of the worst coronavirus surges in the nation.

Even before Air Force One touched down on July 31, the fallout was apparent: Five Secret Service agents already on the ground had to be replaced after one tested positive for the coronavirus and the others working in proximity were presumed to be infected, according to people familiar with the situation.

The previously unreported episode is one of a series of examples of how Trump’s insistence on traveling and holding campaign-style events amid the pandemic has heightened the risks for the people who safeguard his life, intensifying the strain on the Secret Service.

In the past two months, dozens of Secret Service agents who worked to ensure the security of the president and Vice President Pence at public events have been sickened or sidelined because they were in direct contact with infected people, according to multiple people familiar with the episodes, who spoke on the condition of anonymity to describe the incidents.

Despite that, Trump has continued to hold large gatherings — most dramatically at the White House on Thursday night, when he delivered his acceptance speech at the Republican National Convention before a crowd of 1,500 people seated closely together on the South Lawn, with few masks in sight. The vast majority were not tested for the coronavirus ahead of time.

Trump’s actions rebuff the scientific consensus that the best way to tamp down the spread of the virus is to avoid large gatherings and close quarters. Critics say his refusal to abide by those guidelines is imposing unnecessary risks on Secret Service staffers, who have no choice in whether to accompany the president.

“Never before has the Secret Service run up against a president so intent on putting himself first regardless of the costs, including to those around him,” said Ned Price, a national security expert and former CIA analyst. “And by maintaining a rigorous travel schedule and otherwise flouting public health guidance, he is demanding that agents add to their already considerable professional risk in ways that are qualitatively different than what they signed up for.”

White House spokesman Judd Deere said in a statement that the president “takes the health and safety of everyone traveling in support of himself and all White House operations very seriously, as well as those dedicated to covering him and this Administration.”

“When preparing for and carrying out any travel, White House Operations collaborates with the Physician to the President and the White House Military Office, to ensure plans incorporate current CDC guidance and best practices for limiting covid-19 exposure to the greatest extent possible,” Deere added.

The Secret Service declined to provide information about the number of its employees who have tested positive. Secret Service Director James Murray told personnel last month in staff messages that the numbers of positive cases had been rising, a trend he attributed to the agency’s increased testing in previous weeks, according to two people familiar with the communication.

In a statement to The Washington Post, spokeswoman Catherine Milhoan said that the agency “continues to methodically assess the unique requirements necessary to operate in the ongoing pandemic environment.”

“The agency takes all appropriate precautions to protect our workforce, our protectees, and the public from exposure to covid-19,” she added. “Precautions include, but are not limited to, maintaining appropriate social distancing, the provision and use of PPE, routine testing when appropriate, whether before, during, or after official travel.”

In recent weeks, the agency has steadily ramped up its efforts to fend off the virus. To prepare for the pared-down Democratic and Republican conventions this month in Milwaukee and Charlotte, the Secret Service increased testing protocols, requiring that any employee traveling to either convention be tested before leaving for the assignment and within a few days after returning, according to administration officials.

The regimen was put in place after some discontent and anxiety percolated inside the agency earlier this summer, with agents and officers privately complaining that the White House and the Secret Service were not properly addressing the risks they faced on the road, according to people familiar with the concerns. Testing and protective equipment had been offered sparingly and inconsistently, some argued.

After the incident in Tampa in July, two agents who were assigned to stand guard at Trump’s private club in Bedminster, N.J., fell sick with coronavirus symptoms this month while the president golfed. It was his third trip there this summer. One law enforcement official who spoke on the condition of anonymity to describe internal discussions said agents on the president’s detail warned colleagues on the Bedminster trip not to share information about the illness because media coverage would anger the president.

Milhoan said agents did not test positive for the coronavirus at Bedminster, but she declined to comment on whether agents working at the site fell ill or were replaced.

The men and women of the Secret Service live by a unique code, one in which they pledge that they are willing to take a bullet for the president to safeguard a stable democracy.

But this new virus that has killed nearly 180,000 Americans in eight months has prompted some to ask a new question: Should they be required to risk contracting a lethal disease — and infecting a loved one — to secure an event that does not follow health protocols?

The stakes were driven home in June, when six advance staffers and two agents tested positive for the virus hours before Trump took the stage in a Tulsa arena for a campaign rally that health officials warned could accelerate the spread of the outbreak.

The Secret Service was forced to order dozens of agents to quarantine for two weeks after returning from Oklahoma, creating a strain to find agents to cover for their assignments. A third agent later tested positive. The Secret Service’s Oklahoma field office also arranged separate testing at a nearby hospital for local agents who had worked at the rally.

Days later, supervisors had to scramble to find enough healthy agents for a security team to prepare for a Pence trip to Arizona on June 30, according to two senior administration officials.

Before Pence’s visit, however, some of the agents who were preparing for his arrival in Arizona — at the time a hot zone for the virus — fell ill. The vice president was forced to postpone his trip to give the Secret Service time to round up healthy replacements, as The Post previously reported.

During his visit to Tampa last month, Trump spoke to a group of supporters on an airport tarmac in front of Air Force One and later attended a private fundraiser. He used his appearance to highlight an endorsement from local sheriffs and warned that former vice president Joe Biden and other Democrats would sow chaos in cities.

It was a particularly hazardous time for the trip. Florida was then experiencing a surge of coronavirus cases and had recorded four straight days of record-setting deaths tied to the virus. On the day of Trump’s visit, 257 people died of the disease in the state, the highest daily death toll in Florida since the virus first reached the United States.

The president’s indifference to safety protocols as he travels to hot spots has elevated the risks, critics say. Trump, his staff and supporters rarely wear masks and often gather in large groups.

Secret Service agents providing security for the president have sought to avoid commercial planes so they are not exposed to the traveling public, meaning that they at times have had to drive hundreds of miles to reach their assignments, government officials confirm. Agents helping coordinate security for the president’s visually dramatic celebration with fireworks in front of Mount Rushmore on the night of July 3 drove in their own cars from regional field offices as far away as Texas to reach the South Dakota landmark, the officials said.

The Secret Service recently began contracting charter planes to transport agents to key events, including the Democratic National Convention.

But even the best practices don’t eliminate all risks. Although everyone aboard the plane to Milwaukee wore protective masks and kept several seats open for social distancing, one agent on the plane tested positive for the coronavirus upon arriving, an administration official said. The official said the Secret Service relieved from duty a few agents who sat in proximity to the infected agent and instructed them to quarantine.

But other agents who had been on the plane still performed their assignments that day to stand guard at the Milwaukee convention, according to two people familiar with the events.

Alice Crites and Josh Dawsey contributed to this report.