We consider the two-nucleon system at next-to-next-to-next-to-leading order (N 3LO) in chiral effective field theory. The two-nucleon potential at N 3LO consists of one-, two- and three-pion exchanges and a set of contact interactions with zero, two and four derivatives. In addition, one has to take into account various isospin-breaking and relativistic corrections. We employ spectral function regularization for the multi-pion exchanges. Within this framework, it is shown that the three-pion exchange contribution is negligibly small. The low-energy constants (LECs) related to pion-nucleon vertices are taken consistently from studies of pion-nucleon scattering in chiral perturbation theory. The total of 26 four-nucleon LECs has been determined by a combined fit to some np and pp phase shifts from the Nijmegen analysis together with the nn scattering length. The description of nucleon-nucleon scattering and the deuteron observables at N 3LO is improved compared to the one at NLO and NNLO. The theoretical uncertainties in observables are estimated based on the variation of the cut-offs in the spectral function representation of the potential and in the regulator utilized in the Lippmann-Schwinger equation.