We predict high-gain x-ray lasing in diatomic molecules by ultrafast core ionization of the C K- and O K-edges in CO and the N K-edge in N2 with an x-ray free-electron laser source. We solve generalized Maxwell-Bloch equations, keeping track of the electronic and nuclear degrees of freedom. By controlling the molecular alignment and thereby the alignment of the transition dipole moment polarization control of the emitted x-ray radiation is achievable. Despite the broad fluorescence bandwidth, the amplified x-ray emission shows a narrow spectrum. Preparing the initial vibrational quantum state, the x-ray emission frequency can be tuned within the fluorescence band.