Edgartown police have located a missing Vineyard teenager unharmed, following an intense investigation that covered three states and involved numerous police agencies.

Megan Donovan, 15, of Edgartown, was last seen on May 23, departing the Island on the first Steamship Authority ferry to Woods Hole. Police believe she took a bus to Providence, R.I., and then traveled to Connecticut. She was traveling with Gregory Mooney, 20, of Mashpee, police said.

Police used a variety of investigative techniques, including publicity on social media sites, in attempting to locate Ms. Donovan. Late Tuesday evening, Mr. Mooney made a phone call to a friend on Cape Cod.

“The owner of the phone told Edgartown police that he had encountered a young couple at a local diner in Wallingford, Conn. and the male asked to borrow his phone to make a call,” said Edgartown police Lieut. Chris Dolby in a news release. “He said the male, along with his female companion, had now taken off, running away from the diner.”

At the request of Edgartown police, the Wallingford police department searched for the couple throughout the night. On Wednesday morning, they located both Ms. Donovan and Mr. Mooney and they were taken into custody.

Ms. Donovan’s parents left the Island immediately for a reunion with their daughter in Wallingford.

Mr. Mooney faces charges of shoplifting and risk of injury to a minor in Connecticut, in connection with the incident.

According to Falmouth district court records, Mr. Mooney was scheduled to appear in court on May 29 for a pretrial hearing on two larceny charges.