New York City Mayor Bill de Blasio lashed out at the Trump administration and denied any wrongdoing after a letter from U.S. Customs and Border Protection emerged stating the mayor and his security detail illegally crossed over the U.S.-Mexico border during a visit to Texas last month.

During a news conference Wednesday at the Marcy Houses in Brooklyn, de Blasio called the allegations “absolutely ridiculous” and an attempt by the Trump administration to create a distraction amid the immigration debate involving illegal immigrant children.

“[This] is another way to distract [the American people] from an inhumane policy,” de Blasio said about the letter being released about two weeks after it was issued.

“Threats by the Trump administration will not stop me from speaking out and won’t stop my fellow mayors from speaking out,” the mayor said.

In a letter sent on June 25 and obtained by Fox News, CBP said de Blasio and his security detail, run by the New York Police Department, illegally crossed the border near El Paso on June 21. The mayor and his security detail were spotted taking photos by a Border Patrol agent on the Rio Grande River flood plain south of the Tornillo, Texas, Port of Entry.

They had been denied earlier in the day entrance to a holding facility for immigrant children, which de Blasio said on Wednesday “made no sense.”

The letter said a border patrol agent approached a group of 10 to 12 people and asked if they received authorization from a Border Patrol or public affairs officer to be in the area. New York Police Department inspector Howard Redmond was with de Blasio and the group did not have a Border Patrol agent or public affairs officer with them, according to the letter.

When asked how they entered the vicinity, the group reportedly pointed toward Mexico.

“The agent informed the group that they had illegally crossed the United States/Mexico Border at a place other than a designated port of entry and that this was a violation of federal law,” the letter read.

The agent ordered the group to remain at the scene, but they disregarded the request and walked across a river bed and back into Mexico, according to the letter. The agent had left to get a supervisor to take the group to an official crossing for an inspection per federal law.

DE BLASIO: 'PROFOUNDLY RACIST' TRUMP 'LIVING OUT A TABLOID APPROACH' TO THE WH

Just before 4 p.m. on the same day, a vehicle carrying de Blasio, Redmond and the rest of the group arrived at the Tornillo Port of Entry to head back into the U.S., the letter stated.

De Blasio rebutted the allegations on Wednesday, saying he consulted with Border Patrol agents and a supervisor and had obtained permission to cross over the border to Mexico.

“While there, we were told where the border line was and we respected it. We came back the exact same way, both times showed passports and went through with the approval of the agents at the entry point,” the New York City mayor said. “At no point did we disregard any of the instructions from the federal authorities.”

The mayor did not address walking across the border.

The office of Austin Mayor Steve Adler told Fox News in a statement that de Blasio and his security detail “were neither apprehended nor detained.”

“They observed a border patrol agent briefly speak with a United States law enforcement officer and then the agent left,” the statement added.

De Blasio’s spokesman, Eric Phillips, said in an earlier statement to Fox News the mayor and his security detail had received direct approval to cross “at this port of entry,” despite what the letter described.

"The Mayor crossed the border with the direct approval and under the supervision of the border patrol supervisor at this port of entry. Any suggestion otherwise is a flat out lie and an obvious attempt by someone to attack the Mayor because of his advocacy for families being ripped apart at the border by the Trump Administration,” Phillips said.

U.S. Customs and Border Protection could not immediately be reached for comment.

De Blasio has been a staunch critic of Trump and his immigration policies. He vowed to protect all illegal immigrants in New York City when Trump was elected president in 2016.

On Wednesday, the mayor continued his attack on President Trump and his policies.

“Here’s my message to President Trump, and it’s a message I can say on behalf of the people of his hometown. We simply won’t stand for this. We won’t stand for a policy that separates children from their parents. I won’t stand for it. This is the ultimate city of immigrants,” the mayor said.

He continued: “So I won’t stand for it and I won’t be silenced. And I won’t accept any effort to intimidate.”

De Blasio was visiting the U.S.-Mexico border with about 20 other mayors from across the nation when the alleged incident occurred.

Aaron Hull, the chief patrol agent for the Border Patrol's El Paso Sector, had sent the letter to NYPD Commissioner James O'Neill.

The Associated Press contributed to this report.