Justice Brett M. Kavanaugh was on the Trump administration’s side at Oct. 10 oral arguments, but the president’s first high court pick could be the swing vote in the contentious immigrant detention case.

It may well break along the usual ideological lines, but Justice Neil M. Gorsuch’s questioning of both sides’ arguments showed that he wasn’t fully buying either.

How Gorsuch votes may depend on whether he views this case as closer to Jennings v. Rodriguez—where he joined his...