The lawsuit, which seeks class-action status on behalf of hundreds of similarly detained immigrants, alleges that the government held them longer than federal law allows on immigration charges, which are civil violations. Meanwhile, the suit says, agents hunted for evidence to tie them to terrorism.