A former federal worker went berserk on a Hong Kong-to-Newark flight today, claiming to be a CIA agent poisoned by the spy agency before passengers wrestled him to the cabin floor, sources said.

Port Authority cops and the FBI took the deranged passenger into custody at Newark Liberty International Airport around 2 p.m., roughly 15 minutes after the plane landed, and said they found no evidence of toxins on board.

The suspect identified himself to passengers as Daniel M. Perry, who sources confirmed was a former federal employee, though they did not say where he had worked.

“Six hours before we landed, there was a passenger who started screaming about national security and the CIA. He was very paranoid,” said Jacques Roizen, 44, a recruiting consultant who helped restrain the 35-year-old perp.

“When he started reaching for his pockets, people got scared. Then we put him on the ground with the help of a few passengers.

“We spent five hours trying to calm him down. He was handcuffed both hands and feet,” said Roizen. “He was afraid of being killed. He was afraid of the FBI. He wanted the plane diverted to Canada.”

One passenger said Perry made reference to National Security Administration leaker Edward Snowden, who is staying in Hong Kong.

“He said he had information related to Snowden and the information that he released and that was why he was in danger,” said Peter Jones.

Roizen described a frightening scene as Perry flipped out.

“He said he was poisoned and that he was going to die. He was in the aisle when this all went down. It was really sudden. We ended up on the floor,’’ Roizen said.

“A flight attendant gave us plastic handcuffs. He kept pushing back with his feet, so we put some on his feet as well,” he said. “You didn’t have time to think. There’s a guy screaming on the plane. So we just put him on the floor.”

Sources said the flight landed about 1:43 p.m. and was directed to a remote area so PA Emergency Service Unit cops and FBI agents could board and assess the situation.

They later put Perry, wearing a blue hooded jacket, into an ambulance, where he went berserk again despite his restraints, sources said.

He was taken to University Hospital in Newark for a psychiatric examination.

Perry has addresses at his parents’ home in upstate Binghamton and also in Washington, DC., according to public records

His mother, Susan Perry, said, “Oh my God,” and “I have to call his doctor” when reached at her home by The Post before she hung up.

rfredericks@nypost.com