A mother has told of her horror when the “man with a light” she believed was an imaginary figure in her son’s nightmares turned out to be a real intruder outside their home.

Melissa Rodrigues, who lives in Waikanae in New Zealand, said that when her three-year-old son told her about the shadowy man appearing outside his bedroom window last month she assumed he had been dreaming.

But when he woke her and her husband up screaming on 26 June, they realised the threat was real.

“At 5.30 in the morning he let out an absolutely gut-wrenching scream from his room,” Ms Rodrigues told Stuff.nz. “I knew something wasn't right.”

The little boy led her and her husband out into the garden, where they found their gate wide open and footprints leading across the garden.

Ms Rodrigues called the police and they advised her to keep watch for the intruder in case he appeared again.

They used an app called Salient Eye that turns smartphones into motion-sensing cameras (AFP/Getty Images)

Wanting to catch him on camera but unable to afford home CCTV, she and her husband converted an old smartphone into a surveillance system using a free app called Salient Eye.

They set it up in the garage window facing the house and sent her son to his grandmother before waiting to see if the man would return for a third time on Saturday.

At 4.40am, the phone’s motion sensor was triggered and photos started automatically flooding Ms Rodrigues’ email, showing a hooded figure wearing black outside the porch window.

Ms Rodrigues and her husband were watching in horror from the other side of the house, hidden in their lounge.

“I dropped everything and called the police, they came really quickly,” she told NewstalkZB.

“We didn't want to risk being seen because we didn’t know who they were, how many they were, whether they had weapons…we didn't want to put ourselves in harm’s way.”

The family called police while the phone app was photographing the intruder outside their house (Salient Eye)

The unfolding scenes were caught on camera by the app as police with search dogs stormed the garden, searching for the supect.

Police told Stuff.nz that a 15-year-old boy who was previously known to the local force had been detained and referred to a young offenders’ unit for stealing cigarette butts.

“This incident was able to be sorted out very quickly, thanks to the excellent information supplied by the family, and the police working quickly, together with the help of the mobile phone app,” a spokesperson said.

Ms Rodrigues said she had talked to elderly neighbours who had heard noises outside their homes at night and had tools go missing said there had been no more disturbances since the teenager was detained.

Her son was too frightened to go back into his bedroom at first but he is now sleeping soundly after his mother showed him pictures of the “man with a light” being caught.

“If it wasn't for him alerting us, we never would have known,” she told NewstalkZB. “We can all sleep at night now.”