​China on Tuesday warned the criminals they claim are behind weeks-long protests in Hong Kong not to “play with fire” and ​vowed to crack down on the ​organizers, signaling that Beijing has no intention of giving in to their demands.

“We would like to make it clear to the very small group of unscrupulous and violent criminals and the dirty forces behind them: Those who play with fire will perish by it,” ​said Yang Guang, the spokesman for the Chinese cabinet’s Hong Kong and Macao Affairs Office. “Don’t ever misjudge the situation and mistake our restraint for weakness.”

Hong Kong ​​has been rocked by sometimes violent unrest since June over now-suspended plans that would have allowed suspects from Hong Kong to be extradited to mainland China, and protesters have since included demands for democratic reforms in the government.

Beijing has not intervened in the demonstrations, allowing law enforcement in Hong Kong to deal with the massive protests.

But Yang singled out “brazen, violent and criminal actors” and the “meddling hands behind the scenes” for stoking discord.

“As for their punishment, it’s only a matter of time,” he said.

The sharp words from China follow violence that accompanied a general strike in the former British colony on Monday that blocked trains and caused hundreds of international flights to be canceled.

Police engaged in running battles with activists, shooting tear gas and rubber bullets at the protesters, who responded by tossing bricks at the officers and igniting fires.

Carrie Lam, Hong Kong’s Beijing-backed chief executive, warned that the city is “on the verge of a very dangerous situation.”

With Post wires