It is an electron capture. Because the neutron is heavier than sum of proton and electron mass, this capture requires additional energy. This energy is brought in by the electron thanks to the following mechanism:
Electrons are fermions, so due to the Pauli exclusion principle, there can not be 2 electrons in the same quantum state. When a star is collapsing, its core is compressed and electrons are getting so close together that the Pauli exclusion kicks in. In order for the electrons to occupy the same place, they must differ in energy (to be in a different quantum state). During the continued compression, more and more electrons are cramped up in every location of the core volume. Because all low energies are already occupied (the electron gas is degenerate), the electrons must get into higher and higher energies. This energy is provided by the compression, which must overcome the electron degeneracy pressure (in other words: the compression must add more and more energy to the electrons to push them to higher energies). At some point, the highest energy electrons have enough energy to bridge the gap between neutron mass and (proton + electron) mass. So the highest energy electrons fuse with the protons.
This particular process was not observed in laboratory, because we cannot create the required pressure. But a related process was observed: an electron capture from K shell in an atom with proton-rich nucleus. In this process the required energy is supplied by the energy difference between the initial and final nucleus: the initial nucleus has too many protons, which must therefore occupy higher energy levels, again due to Pauli exclusion. This is also know as the K-capture.
The electron capture is facilitated by the weak interaction and it is well understood process.
Note: the remaining electrons (below the required energy) in neutron star stay around, because they cannot fuse (not enough energy). These remaining electrons are still degenerate and they prevent the neutrons to beta decay back into proton + electron. There is not enough energy available to put this new electron into the electron degenerate gas.