Cell membranes are a key element of life because they keep the genetic material and metabolic machinery together. All present cell membranes are made of phospholipids, yet the nature of the first membranes and the origin of phospholipids are still under debate. We report here the first detection in space of ethanolamine, NH$_2$CH$_2$CH$_2$OH, which forms the hydrophilic head of the simplest and second most abundant phospholipid in membranes. The molecular column density of ethanolamine in interstellar space is $N$=(1.51$pm$0.07)$times$10$^{13}$ cm$^{-2}$, implying a molecular abundance with respect to H$_2$ of (0.9-1.4)$times$10$^{-10}$. Previous studies reported its presence in meteoritic material but they suggested that it is synthesized in the meteorite itself by decomposition of amino acids. However, we find that the proportion of the molecule with respect to water in the interstellar medium is similar to the one found in the meteorite (10$^{-6}$). These results indicate that ethanolamine forms efficiently in space and, if delivered onto early Earth, it could have contributed to the assembling and early evolution of primitive membranes.