“Many Democrats are deeply concerned about the fact that their ‘leadership’ wants to denounce and abandon the great men and women of ICE, thereby declaring war on Law & Order,” Mr. Trump tweeted Monday night. “These people will be voting for Republicans in November and, in many cases, joining the Republican Party!”

On Monday morning, he recirculated a message from the Department of Homeland Security that said Customs and Border Protection and ICE would be “sharing stories of the brave men and women who put their lives on the line every day with the sole objective of protecting our nation.” The two agencies posted news of their work breaking up a human smuggling ring, shutting down a drug trafficking operation and apprehending “wanted criminals” at the border, including a man in Laredo, Tex., wanted for sex-related offenses against a child.

But when the White House shared the stories, it used them to attack senators whom Mr. Trump considers political rivals. The White House did not respond to a request for comment about the tweets.

Ms. Harris responded with a Twitter broadside against the Trump administration and its practice — recently suspended — of separating migrant children from their parents to carry out a “zero tolerance” policy of subjecting all immigrants who cross the border unlawfully to criminal prosecution.

“As a career prosecutor, I actually went after gangs and transnational criminal organizations,” Ms. Harris wrote. “That’s being a leader on public safety. What is not, is ripping babies from their mothers.”

She also tried to capitalize financially on Mr. Trump’s attack, asking supporters to sign on with her political organization.

“No matter what they say, I will never stop fighting to hold Trump and his administration accountable and I will never stop speaking out against their immoral policies like separating parents from their families,” Ms. Harris said in a tweet with a link to her sign-up page.

It was not clear whether the White House messages violated any ethics rules, but they did break with the practice of past administrations of refraining from posting overtly partisan content singling out public figures on official accounts. The Trump administration has shown little regard for such traditions and has not hesitated to use agencies’ social media accounts to boost the president personally, such as when the White House instructed cabinet officials to mark his 500th day in office and some responded with fawning tweets praising him.