Molecular dynamics simulations and density functional theory have been performed to investigate the spontaneous encapsulation of 1-butyl-3-methylimidazolium chloride ([Bmim][Cl]) into single-walled carbon nanotubes (SWCNTs). This phenomenon can be attributed to the van der Waals attractive force, hydrogen bonds and especially the π-π stacking effect. The [Bmim][Cl] molecules enter SWCNTs with larger diameters more rapidly, showing an interesting dependence on tube size. A high temperature is not beneficial to, and may even disrupt, the encapsulation of the [Bmim][Cl] molecules. It is also worth noting that the graphene nanoribbon entering the SWCNT would have an extremely different effect on this encapsulation process from when they wrap around the outer surface. Furthermore, the [Bmim][Cl] molecules can assist water transport in the SWCNT by expelling water molecules from the SWCNT. The proposed discoveries eventually provide a powerful way to fabricate nanoscale materials and devices and tune their properties.