Context. IRAS 19312+1950 is an isolated infrared source that exhibits a characteristic quasi-point-symmetric morphology in the near-and mid-infrared images and is also very bright in molecular radio lines. Because of its unique observational characteristics, various observational studies have been conducted and several hypotheses have been proposed regarding its origin, which is still unclear. So far, it has been suggested that it could be a peculiar evolved star, a young stellar object, or even a red nova remnant. Regardless of which type of object it is ultimately classified as, IRAS 19312+1950 is exceptionally bright in the infrared and molecular radio lines and therefore will undoubtedly be crucial as a prototype of this kind of object having a peculiar nature or unusual evolutionary phase. Aims. This study aims to reveal the molecular composition of the central part of IRAS 19312+1950 by performing an unbiased molecular radio line survey and discussing the origin of the object from a molecular chemical point of view. Methods. We carried out a spectral line survey with the Institut de Radioastronomie Millimtrique 30 m telescope towards the centre of IRAS 19312+1950 in the 3 and 1.3 mm windows with a frequency coverage of 83.9–91.8 and 218.2–226.0 GHz, respectively. Results. In total, 28 transition lines of 22 molecular species and those isotopologues are detected towards IRAS 19312+1950, some of which exhibit a broad and a narrow component. Seventeen thermal lines and one maser line are newly detected. The molecular species of C17O, 30SiO, HN13C, HC18O+, H2CO, and c-C3H2 are detected for the first time in this object. We calculated the optical depths of the transition lines of 13CO, C18O, HCN, H13CN, and C2H, and determined the rotational temperatures, column densities, and fractional abundances of the detected molecules. We got the isotopic ratios of 12C/13C, 14N/15N, 16O/18O, 16O/17O, 18O/17O, 28Si/30Si, and 29Si/30Si in IRAS 19312+1950 and the values were compared to those of evolved stars, red novae, young stellar objects, and the Sun. The intensities of the molecular radio lines of IRAS 19312+1950 were compared with those of different categories of objects, indicating that the spectral pattern of the broad-line region is similar to that of a red nova or a low-mass young stellar object, while the narrow-line region behaves like an envelope of the asymptotic giant branch star. Conclusions. Our results, in combination with previous studies, favour the hypothesis that IRAS 19312+1950 might be a red nova remnant, in which the progenitors that merged to become a red nova may have contained at least two evolved stars with oxygen-rich and carbon-rich chemistry, respectively.