NEW YORK — It took less than three days for $17 million to disappear from ATMs across New York in a scam that went viral on TikTok and that city officials say is linked to a youth jobs program, according to two law enforcement officials briefed on the matter.

The withdrawals, using payment cards issued to thousands of young people in the program, should have given users access to only that week’s earnings — perhaps several hundred dollars at most. Instead, they opened a spigot of unlimited cash available in sums of $10,000, $20,000 and even $40,000 per ATM.

There were as many as 30,000 cards issued to 14- to 24-year-olds who could not be paid via direct deposit. The fraudulent use, from July 11-13, is being investigated by the city agency that oversees the program and by the Police Department’s Financial Crimes Task Force.

Some of the young people in the program were selling their cards for $1,000 apiece, according to the law enforcement officials, who spoke on the condition of anonymity because they were not authorized to speak publicly about an active investigation.

In videos on TikTok and Instagram around the time the scam was underway, some teenagers and adults boasted about it and encouraged people to sell their cards to them.

“We’re making bread; we’re printing money right now,” one man said in a video posted on TikTok. Referring to the jobs program, the Summer Youth Employment Program, he said: “If you work SYEP, hit me up.”

Other TikTok users warned people about falling for the “SYEP scam.”

A spokesperson for the agency that oversees the program, the Department of Youth and Community Development, suggested in a statement that the young people whose cards had been used for illicit activity were victims of criminals who had exploited their naivete.

“We are deeply disturbed by scammers preying on our participants just as they started their work assignments to support themselves and their families,” spokesperson Mark Zustovich said. He also said no taxpayer funds had been lost to the fraud; it was not clear who would ultimately be responsible for absorbing the cost of the illicit withdrawals.

Many elements of the scam remain unclear, including how it began, what made it possible, how many of the payment cards and ATMs were used, and who exactly made the withdrawals. Zustovich declined to comment on these specifics, including how much money had been taken.

The jobs program is the largest of its kind in the United States, with 100,000 participants this year. It offers young people, many from poor and minority families, what are often their first formal jobs and their first direct interaction with the financial system.

Those enrolled in the program are placed in various industries for six-week stints, with participants ages 16 to 24 paid the $16.50 minimum wage for up to 25 hours a week. Younger workers are paid less. About 70 community-based organizations operating under contracts with the city help place the young people in jobs.

Participants with bank accounts are paid by direct deposit. Since 2003, those without bank accounts have received payment cards that can be taken to ATMs to obtain their earnings in cash. Roughly 30,000 were set up to be paid by card this year, according to the youth department.

The fraud began on a Friday, city officials said. For many in the program, it was their first payday ever.