Somerville Mayor Joseph Curtatone will sign an executive order barring city police from holding people solely to allow federal agents to pick them up for suspected immigration violations.

Curtatone said in a phone interview Tuesday that the order is “what’s morally responsible to protect families in our community.” The mayor plans to sign the order Thursday.

Under terms of the directive, Curtatone said, police will only hold someone for US Immigration and Customs Enforcement if the agency has a criminal warrant or if there is a “legitimate law enforcement purpose,” beyond immigration status, for keeping a suspect in custody after bail is posted or a judge releases the person.