The $^8$Li($n,gamma$)$^9$Li reaction plays an important role in several astrophysics scenarios. It cannot be measured directly and indirect experiments have so far provided only cross section limits. Theoretical predictions differ by an order of magnitude. In this work we study the properties of $^9$Li bound states and low-lying resonances and calculate the $^8$Li($n,gamma$)$^9$Li cross section within the no-core shell model with continuum (NCSMC) with chiral nucleon-nucleon and three-nucleon interactions as the only input. The NCSMC is an ab initio method applicable to light nuclei that provides a unified description of bound and scattering states well suited to calculate low-energy nuclear scattering and reactions. Our calculations reproduce the experimentally known bound states as well as the lowest $5/2^-$ resonance of $^9$Li. We predict a $3/2^-$ spin-parity assignment for the resonance observed at 5.38 MeV. In addition to the a very narrow $7/2^-$ resonance corresponding presumably to the experimental 6.43 MeV state, we find several other broad low-lying resonances. Our calculated $^8$Li($n,gamma$)$^9$Li cross section is within the limits derived from the 1998 National Superconducting Cyclotron Laboratory Coulomb-dissociation experiment [Phys. Rev. C {bf 57}, 959 (1998)]. However, it is higher than cross sections obtained in recent phenomenological studies. It is dominated by a direct E1 capture to the ground state with a resonant contribution at $sim0.2$ MeV due to E2/M1 radiation enhanced by the $5/2^-$ resonance.