The incident happened on May 3 and the accused had taken the girl with an intention to rape her, they added.
However, the girl's 70-year-old grandmother reached in time and raised an alarm, following which the accused was caught by locals and thrashed.
He was later arrested.
The girl stays with her grandmother and mother in a shanty in Govindpuri area. The girl was sleeping with her grandmother on May 3 when she suddenly woke up and stepped out, police said.
Meanwhile, her grandmother also woke up and started looking for her. She was informed by someone that they had seen the girl going towards Navjeevan Camp.
The elderly woman reached the area and managed to locate the accused person's shanty. She saw him trying to force himself on her granddaughter and raised an alarm.