A man carrying a knife broke into the White House hours after Barack Obama had left, in one of the biggest breaches of US presidential security in years.

Omar Gonzalez, 42, was charged with unlawfully entering a restricted areas while carrying a "deadly or dangerous weapon", according to an affidavit released by the US attorney's office on Saturday. 

Gonzalez scaled a fence on Friday local time and was carrying a folding knife with a 9cm serrated blade, according to the secret service who was in charge of White House security.

The incident is one of the most significant breaches at the White House since Obama became president. The complex is a heavily guarded by secret service agents, snipers and surveillance equipment. 

Shortly before the intrusion, Obama and his daughters had departed for Camp David. His wife, Michelle Obama, had travelled separately to the presidential retreat in nearby Maryland.

"Every day the Secret Service is challenged to ensure security at the White House complex while still allowing public accessibility to a national historical site," the agency said in a statement.

"Although last night the officers showed tremendous restraint and discipline in dealing with this subject, the location of Gonzalez's arrest is not acceptable." 

In October last year, Miriam Carey, 34, of Connecticut, was shot dead in a police chase after she drove her car into a barrier at the White House. Her young daughter was in that car at the time.

Source: Agencies