The origin of nebular HeII emission, which is frequently observed in low-metallicity (O/H) star-forming galaxies, remains largely an unsolved question. Using the observed anticorrelation of the integrated X-ray luminosity per unit of star formation rate ($L_X/{rm SFR}$) of an X-ray binary population with metallicity and other empirical data from the well-studied galaxy I Zw 18, we show that the observed HeII 4686 intensity and its trend with metallicity is naturally reproduced if the bulk of He$^+$ ionizing photons are emitted by the X-ray sources. We also show that a combination of X-ray binary population models with normal single and/or binary stellar models reproduces the observed $I(4686)/I(Hbeta)$ intensities and its dependency on metallicity and age. We conclude that both empirical data and theoretical models suggest that high-mass X-ray binaries are the main source of nebular HeII emission in low-metallicity star-forming galaxies.