PROVIDENCE, R.I. — A 21-year-old man faces kidnapping and sex trafficking charges after police say he drove three teenage girls from Massachusetts to Rhode Island with plans to prostitute them.

Police said Friday they arrested Derek Miranda of Boston on Thursday night after a 14-year-old girl escaped from a third-floor apartment in Providence and called for help. Authorities said officers entered the apartment and found Miranda and two other girls, ages 14 and 15.

Providence police Maj. David Lapatin said Miranda encountered the three girls Wednesday in Brockton, Massachusetts, and tried unsuccessfully to entice them into prostitution. Lapatin said police are still investigating but allege Miranda encountered the girls the next day and drove them against their will from Randolph, Massachusetts, to Providence.

Lapatin said the girls had not been sold for sex.

“I think we were very, very fortunate to find these girls before anything had happened to them,” he said.

Miranda was being detained by police Friday. It was not clear if he had a lawyer.

Two of the girls were returned to their parents; the third was turned over to Massachusetts child welfare officials.

The girl who escaped from the apartment Thursday night was able to get a message to a friend on social media, Lapatin said.