Two U.S. soldiers in a remote area of Texas were confronted by Mexican soldiers who thought the Americans had crossed into Mexico, U.S. officials said Tuesday. The Mexican troops reportedly removed a weapon from the American soldier who was armed.

U.S. President Donald Trump warned Mexico Wednesday morning over Twitter over the incident. Trump wrote, "Mexico’s Soldiers recently pulled guns on our National Guard Soldiers, probably as a diversionary tactic for drug smugglers on the Border. Better not happen again! We are now sending ARMED SOLDIERS to the Border. Mexico is not doing nearly enough in apprehending & returning!"

Read more: FBI: Armed U.S. border group was training to 'assassinate Soros, Obama and Clinton'

U.S. Northern Command, which manages military support for Customs and Border Protection, said the Americans were in a CBP vehicle in a remote area in the vicinity of Clint, Texas.

The incident happened on April 13 and was first reported by Newsweek, which said one of the Mexican military members removed a service pistol from the hip of one of the Americans and threw it inside the U.S. government vehicle.

A Northern Command statement to The Associated Press on Tuesday said an inquiry by the Defense Department and CBP revealed that the Mexican military members believed they were on Mexican territory at the time they confronted the Americans. The incident happened on a slice of U.S. territory south of the border wall but north of the actual border.

"After a brief discussion between the soldiers from the two nations, the Mexican military members departed the area," Northern Command said. "The U.S. soldiers immediately contacted CBP, who responded quickly. Throughout the incident, the U.S. soldiers followed all established procedures and protocols." It said an inquiry is ongoing.

The U.S. troops are at the border as part of a Trump administration effort to reduce illegal crossings.