The satellite component is recognized as a promising solution to complement and extend the coverage of future Internet of things (IoT) terrestrial networks (TNs). In this context, a study item to integrate satellites into narrowband IoT (NB-IoT) systems has been approved within the 3rd Generation Partnership Project (3GPP) standardization body. However, as NB-IoT systems were initially conceived for TNs, their basic design principles and operation might require some key modifications when incorporating the satellite component. These changes in NB-IoT systems, therefore, need to be carefully implemented in order to guarantee a seamless integration of both TN and non-terrestrial network (NTN) for a global coverage. This paper addresses this adaptation for the random access (RA) step in NB-IoT systems, which is in fact the most challenging aspect in the NTN context, for it deals with multi-user time-frequency synchronization and timing advance for data scheduling. In particular, we propose an RA technique which is robust to typical satellite channel impairments, including long delays, significant Doppler effects, and wide beams, without requiring any modification to the current NBIoT RA waveform. Performance evaluations demonstrate the proposal's capability of addressing different NTN configurations recently defined by 3GPP for the 5G new radio system.