A rational 3D hierarchical porous nitrogen-doped aligned carbon nanotubes (HPNACNTs) with well-directed 1D conductive electron paths is designed as scaffold to load sulfur. The HPNACNTs have abundant micropores, mesopores and macropores with a relatively high specific surface area and a large total pore volume. The sulfur-HPNACNTs composite is synthesized for lithium–sulfur batteries by a melt-diffusion of sulfur powders into HPNACNTs scaffolds. Electrochemical tests reveal that the sulfur-HPNACNTs (68.8 wt% sulfur) composite exhibits a high initial discharge capacity of 1340 mAh g−1 at 0.1 C and retains as high as 979 mAh g−1 at 0.2 C after 200 cycles. More importantly, it shows high reversible capacity at high rates (817 mAh g−1 at 5 C). Its enhanced electrochemical performance can be attributed to the excellent electrical conductivity of aligned carbon nanotubes, the synergetic effect of its hierarchical porosity and the restraint of the shuttle effect due to the SxLi … N interactions via the N lone-pair electron.