ABOARD A P-3 ORION, over the Pacific Ocean — The Department of Homeland Security is increasingly going global.

An estimated 2,000 Homeland Security employees — from Immigration and Customs Enforcement special agents to Transportation Security Administration officials — now are deployed to more than 70 countries around the world.

Hundreds more are either at sea for weeks at a time aboard Coast Guard ships, or patrolling the skies in surveillance planes above the eastern Pacific Ocean and the Caribbean Sea.

The expansion has created tensions with some European countries who say that the United States is trying to export its immigration laws to their territory. But other allies agree with the United States’ argument that its longer reach strengthens international security while preventing a terrorist attack, drug shipment, or human smuggling ring from reaching US soil.

“Many threats to the homeland begin overseas, and that’s where we need to be,” said James Nealon, the department’s assistant secretary for international engagement.

A surveillance mission earlier this month with Homeland Security agents in drug transit zones near South America highlights the department’s efforts to push out the border. Just after takeoff from a Costa Rican airfield, a crew of agents aboard a Customs and Border Protection surveillance plane began tracking a low-flying aircraft that appeared to be headed south toward Ecuador.

The aircraft, which intelligence reports reviewed by agents indicated had no flight plan, flew just a few hundred feet above the ocean — an apparent attempt to avoid detection by radar.

“When they are flying that low, they’re probably up to no good,” said Timothy Flynn, a senior detection agent, watching the plane on a radar screen.

An hour later, and hiding in the cloud cover to stay out of sight, the US P-3 pulled up behind the plane. An agent with a long-lens digital camera snapped a string of photos of the plane’s tail number and other identifying details. Flynn radioed the information to authorities in Ecuador who were waiting when the plane landed, arresting seven people and seizing more than 800 pounds of cocaine aboard.

Ecuador may embrace the Homeland Security agents, but other allies say the department’s foreign reach is a stretch.

In Germany, some lawmakers have questioned the department’s counterterrorism Immigration Advisory Program, where travellers at foreign airports are investigated and sometimes interviewed by plainclothes Customs and Border Protection officers before they are allowed to board flights to the United States.

Those US officers can recommend that airlines deny boarding to foreign passengers. A Government Accountability Office report found that the customs officers stopped 8,100 known or suspected terrorists, or individuals with connections to terrorist groups, from travelling to the United States in 2015, the most recent year that data is available.

But Andrej Hunko, a member of Germany’s Left Party, said the actions amount to an extrajudicial travel ban and accused the United States of moving its “immigration controls to European countries.”

Canadians flooded their prime minister’s office in August with letters and emails protesting legislation to allow US customs officers stationed at Canadian airports and train stations to question, search and detain Canadian citizens. Unnamed government officials told the Canadian Broadcasting Corp. that the volume of mail received was “unprecedented” and took officials by surprise.

The measure passed two weeks ago after Ralph Goodale, Canada’s public safety minister, assured Parliament that the US officers would rarely use their authority to question or detain Canadian citizens. More than 400 Homeland Security employees are stationed in Canada — the most of any foreign country — which Goodale called a benefit to both nations.

“We face shared threats from drug smugglers, terrorists and human traffickers, and we could do things over the phone,” Goodale said in an interview. “But there are real advantages to being able to meet and talk to people face to face as you deal with these security threats.”

In Tanzania, Immigration and Customs Enforcement investigators were accused in May of using “Mafia-style” tactics for helping to extradite suspects accused of drug smuggling to the United States before their appeal to block the transfer was concluded.

The costs of the Homeland Security operations abroad also have raised questions by critics in the United States.

One congressional report found that the cost of stationing an Immigration and Customs Enforcement agent overseas is about four times as expensive as a domestic post. And in September testimony to the House Homeland Security Committee, the National Treasury Employees Union raised concerns about plans to deploy additional customs officers abroad amid “critical staffing shortages at the nation’s ports of entry.” The union represents 25,000 Customs and Border Protection employees.

Lawmakers have asked Homeland Security officials to evaluate the costs and benefits of deploying thousands of employees overseas while the department is looking to hire 15,000 new ICE and Border Patrol agents in the United States as part of President Donald Trump’s crackdown on illegal immigration.

Kevin K. McAleenan, acting commissioner of Customs and Border Protection, said nearly 1,000 agency employees are stationed abroad, more than from any other branch of the Department of Homeland Security. They screen passengers at airports, inspect cargo being loaded on ships bound for the United States and train other nations’ customs and border officials.

Additionally, a special tactical unit of Border Patrol agents, known as Bortac, has worked in nearly 30 countries to train in counterterrorism and counternarcotics missions.

Kevin Martinson, the Customs and Border Protection attache at the US Embassy in Nairobi, said a training programme for Kenyan customs officials and its Rural Border Patrol has led to record seizures of narcotics and other smuggled goods.

Martinson, who coordinates the agency’s efforts in nine African countries, said the training has also helped Kenya secure its borders and guard against groups like Al Shabab, a militant organisation based in neighbouring Somalia. He said the US-trained Rural Border Patrol recently repelled an attack by the extremists and captured one of its assailants.

In South Africa, Homeland Security Investigations special agents who are stationed at the US Embassy in Pretoria have targeted drug smugglers, wildlife traffickers and Nigerian scammers. The agents, who work for a division of ICE, are among 300 investigators in nearly 50 countries worldwide.