We have performed the first-principles calculations on the structural, electronic, and magnetic properties of 3d transition-metal nanowires (TMNW4s), Fe4, Co4, and Ni4, encapsulated inside GaN nanotubes (GaNNTs). The results show that, all three types of the TMNW4 encapsulated inside the narrower (6,6) and broader (8,8) GaNNTs are both exothermic. The spin polarization and magnetic moment of the TMNW4@(8,8) systems are larger than those of the TMNW4@(6,6) systems due to more weak restriction of the broader (8,8) GaNNT, but those of these two combined systems are smaller than those of the corresponding freestanding TMNW4. Our results reveal that either the TMNW4@(6,6) or TMNW4@(8,8) systems have high spin polarization and magnetic moment and stably exist in atmosphere for long time and thus can be expected to have potential applications in building nanodevices.