OAKLAND — In a stark reminder of the importance of online safety, police here say an 11-year-old boy was recently raped by a man he met on the internet, who somehow figured out the boy’s address and picked him up from his home.

In the end, authorities say the victim’s father turned the tables on the suspect, taking his son’s phone and posing as the boy until he was able to track the suspect to a gas station on International Boulevard in Oakland. The father then called police, who arrested 29-year-old Ruben Aguilar Aguilar, court records show.

Aguilar now faces 17 felonies, including multiple counts of forcible sodomy, aggravated sexual abuse of a child, using a minor for sex acts, and one count of having child pornography.

Prosecutors say that they met through the chat application WhatsApp. The two allegedly talked about playing video games, and Aguilar told the boy he could win money if they hung out together, according to police. The boy agreed to meet in person but was surprised on March 14, when Aguilar showed up without receiving directions to his home, authorities said.

Police allege that after taking the boy back to his house, Aguilar sexually abused him several times, and that the boy was too frightened to fight back. When it was over, Aguilar allegedly got onto the boy’s phone and deleted their messages, paid the child $25, and then dropped him off, authorities said.

When the boy’s father learned what happened, he posed as his son, chatted with Aguilar until he was able to figure out his location at a gas station, then drove there, verified the man’s identity, and called police, according to court records. The boy later reportedly identified Aguilar to investigators.

After his arrest, Aguilar admitted to receiving lewd images from the boy, authorities said in court filings. He remains jailed with bail set at $250,000, and is set to enter a plea on April 10, court records show.