Phosphorus is considered as a promising anode for Na-ion battery because of its high theoretical capacity of 2595mAhg−1. In this study, two phosphorus-carbon (P-C) composites with well-controlled compositions and nanostructures of P and C have been developed: P@YP composite with P confined within porous structure of YP-80F carbon and P@CNT with unconfined P deposited on the surface of carbon nanotube. The structure and electrochemical performance of these two composites have been studied to illustrate the effect of nanostructures of both C and P. P@YP composite with appropriate amount of P confined in nanopores can accommodate its large volume change upon sodiation/desodiation and enable a stable solid-electrolyte interphase (SEI), ensuring an excellent long-term cycling stability with superior capacity retention of 92% after 100 cycles and 46% after 1000 cycles. In contrast, the P@CNT composite with unconfined P nanostructures shows a rapid capacity decay with capacity retention of ~ 40.6% after 100 cycles, most likely due to unstable SEI during cycling, caused by the large volume changes of unconfined P in the P@CNT composite. The well-designed nanostructured P-C composite with P confined within porous structure of carbon is demonstrated to greatly enhance the electrochemical performance, leading to promising long-term cycling stability.