We have investigated the variation of the structural energy along two transition paths from the layered to the highly condensed phases of BN using the first-principles total-energy pseudopotential method. Along the structural paths considered, the symmetries of the initial layered phases have been maintained, leading from the rhombohedral and hexagonal graphitic phases, which differ in their stacking sequences, into the zinc-blende and wurtzite phases, respectively. Constraining the interlayer distances, the total energies were minimized by allowing the hexagonal rings to stretch and buckle into chair conformation. The paths obtained in this way have activation energy barriers approximately 40% smaller than those in graphite diamond transitions of C, and approximately equal to 0.38 eV/pair for both processes considered when the zero-point motion energy contribution is neglected. The charge densities indicate that strong bonding between the hexagonal layers occurs only in the final stage of the transitions, after the barriers have been crossed, and the structures collapse into the tetrahedrally coordinated phases. From the point of view of electronic structure, at all stages along the transitions, BN displays gaps (calculated within the local-density approximation) larger than 3.5 eV, a minimum which is reached when the activation energy barrier is near a maximum.