We aim to investigate the nature of time-variable X-ray sources detected in the XMM-Newton serendipitous survey. The X-ray light curves of objects in the XMM-Newton serendipitous survey were searched for variability, and coincident serendipitous sources observed by Chandra were also investigated. Subsequent infrared spectroscopy of the counterparts to the X-ray objects that were identified using UKIDSS was carried out using ISAAC on the VLT. We found that the object 4XMM J182531.5–144036 detected in the XMM-Newton serendipitous survey in 2008 April was also detected by Chandra as CXOU J182531.4–144036 in 2004 July. Both observations reveal a hard X-ray source displaying a coherent X-ray pulsation at a period of 781 s. The source position is coincident with a $K=14$ mag infrared object whose spectrum exhibits strong HeI and Br$\gamma$ emission lines and an infrared excess above that of early B-type dwarf or giant stars. We conclude that 4XMM J182531.5–144036 is a Be/X-ray binary pulsar exhibiting persistent X-ray emission and is likely in a long period, low eccentricity orbit, similar to X Per.