Federal immigration officials are blasting a Brockton lawmaker for inciting “panic” after she took to Facebook to warn illegal immigrants about a rumored ICE sweep — a brazen move one fellow lawmaker said could put “lives in danger.”

State Rep. Michelle DuBois wrote on her Facebook page that contacts in the “Latin community” were abuzz over a feared raid yesterday and today by U.S. Immigration and Customs Enforcement officials.

“If you are undocumented don’t go out on the street. If there is a knock on the door of your house and you don’t know who it is, don’t open the door. I ask you to be careful,” DuBois wrote in the post, which attracted hundreds of comments online.

The Democrat would later write that she was “just forwarding a rumor.”

It drew a quick rebuke from ICE officials, who said the agency “does not conduct random sweeps” or release information about operations.

“Any person who actively incites panic or fear of law enforcement is doing a disservice to the community, endangering public safety and the very people they claim to support and represent,” ICE spokesman Shawn Neudauer said about DuBois’ post.

State Rep. Geoff Diehl, a Whitman Republican who represents towns bordering Brockton, questioned where DuBois got her information.

“I think at worst it puts lives in danger,” said Diehl, who co-chaired President Trump’s Massachusetts campaign and is mulling a run for U.S. Senate.

“I think at best it’s a question of ethics,” he said. “If you’re a lawmaker, where you vote on policy, your job is not to undermine current law.”

Brockton police officials, who in some cases could be notified of a ICE sweep, did not respond to multiple calls, and Mayor Bill Carpenter declined to address the pol’s early warning.

“We do not comment on unsubstantiated Facebook posts,” Carpenter said through a spokesman, “even if the source is a state representative.”

Criticism reached as far as Washington, D.C., where Bristol County Sheriff Thomas M. Hodgson — a Republican who’s repeatedly called for tougher immigration enforcement — criticized DuBois in testimony before a House subcommittee on immigration.

“This is an elected official that is potentially giving a heads-up to criminals that otherwise would be picked up through the element of surprise during a raid,” Hodgson later told the Herald by phone. “That’s giving them cover.”

DuBois staunchly defended her post, arguing that it could actually serve ICE to tell them “that everyone in Brockton is aware of ICE’s planned raid (if there was one),” she wrote in a text.

“I support law enforcement. I support police officers. I wasn’t calling for an overthrow,” DuBois later told the Herald before a previously planned event in Brockton last night on immigration issues.

At one point last night, she had a contentious encounter with other gathered media, holding her hand up to block a photographer’s camera and using her own phone to film reporters.

“My comments were responding to a population who are already fearful of police,” she said. “Maybe they (ICE) should be more open about their plans. … They should call me.”

The brouhaha is similar to one a month ago in Haverhill, when a city councilor there also posted on Facebook that ICE had been conducting raids in the city. At the time, Neudauer denied it, telling the press it was a “false” rumor.