A man arrested for climbing a White House fence earlier this year was shot and killed at a suburban Pennsylvania courthouse on Tuesday after he sliced a sheriff's deputy with a knife, the local district attorney said.

Curtis Smith, 34, is accused of entering the lobby of the Chester County Justice Center at about 11 a.m. and slashing a sheriff's deputy on the arm or hand, Chester County District Attorney Thomas Hogan said in a statement.

A second deputy in the lobby drew his weapon and shot Smith, who was treated at the scene but later died at Paoli Hospital, Hogan said.

"The armed attacker was immediately neutralized by the sheriff's deputies," Hogan said in a statement.

The injured deputy was transported to a local hospital and is in stable condition.

Smith, from Coatesville, Pennsylvania, has a criminal record that includes arrests for assault and burglary.

"Smith was arrested by the Secret Service in March for jumping the fence at the White House," Hogan said in the statement.

The courthouse, which was evacuated after gunshots rang out, was closed for the rest of the day. The incident was under investigation by the Chester County Detectives.

In a tear-choked voice, Marcia Gallagher, who works in the court clerk's office, said the atmosphere was tense as authorities evacuated the building.

"We have trained intensively to deal with the threat of an attacker in the Justice Center or any other public building. Today, that training paid off," Hogan said. "This was a model response to a violent incident.