A precision measurement of the nitrogen flux with rigidity (momentum per unit charge) from 2.2 GV to 3.3 TV based on 2.2×106 events is presented. The detailed rigidity dependence of the nitrogen flux spectral index is presented for the first time. The spectral index rapidly hardens at high rigidities and becomes identical to the spectral indices of primary He, C, and O cosmic rays above ∼700 GV. We observed that the nitrogen flux ΦN can be presented as the sum of its primary component ΦNP and secondary component ΦNS, ΦN=ΦNP+ΦNS, and we found ΦN is well described by the weighted sum of the oxygen flux ΦO (primary cosmic rays) and the boron flux ΦB (secondary cosmic rays), with ΦNP=(0.090±0.002)×ΦO and ΦNS=(0.62±0.02)×ΦB over the entire rigidity range. This corresponds to a change of the contribution of the secondary cosmic ray component in the nitrogen flux from 70% at a few GV to <30% above 1 TV.