Britain clinched a last-minute Brexit deal with the European Union on Thursday, but still faced a challenge in getting it approved by parliament.