We investigate the thickness-dependent electronic structure of ultrathin SrIrO$_3$ and discover a transition from a semimetallic to a correlated insulating state below 4 unit cells. Low-temperature magnetoconductance measurements show that spin fluctuations in the semimetallic state are significantly enhanced while approaching the transition point. The electronic structure is further studied by scanning tunneling spectroscopy, showing that 4 unit cells SrIrO$_3$ is on the verge of a gap opening. Our density functional theory calculations reproduce the critical thickness of the transition and show that the opening of a gap in ultrathin SrIrO$_3$ is accompanied by antiferromagnetic order.