Prosecutors said police found weapons and hundreds of rounds of ammunition in a vehicle driven by Omar J. Gonzalez weeks before he jumped the White House fence last year. (U.S. attorney’s office for the District of Columbia )

A federal judge handed down a 17-month prison sentence Tuesday to a disturbed Iraq war veteran who scaled the White House fence last September and helped trigger a shake-up of the Secret Service after he was able to enter the executive mansion.

U.S. District Judge Rosemary M. Collyer ordered Omar J. Gonzalez, 43, to stay out of the District, give up his guns and knives, and allow the Secret Service access to his medical records.

“We often think of the White House as the most secure place in the world, but it was proven that day that it was not,” Collyer said before addressing Gonzalez directly. “No more guns, no more machetes, no more knives, no more tomahawks. Got it?”

His attorney said Gonzalez will live with his father in Southern California after he completes his prison term. He will remain on probation for three years, and his attorney said Gonzalez is expected to receive mental health treatment for the rest of his life.

“I would like to apologize. I am sorry for my actions,” said Gonzalez, who appeared with a full beard and wearing an orange jumpsuit. “I never meant to harm anyone. I want to commit to maintain my treatment that started at the prison.”

Bystander captured video of Omar J. Gonzalez who jumped the fence around the White House Friday and sparked a security alert. Gonzalez got inside the front door of the White House before getting caught. (Alan Pawlinski via YouTube)

Gonzalez pleaded guilty in March to entering or remaining in a restricted building or grounds while carrying a deadly weapon and to assaulting a federal officer, both felonies.

On Sept. 19, Gonzalez ignored orders to stop, barreled through the White House’s North Portico doors, knocked down one officer and was finally tackled in the East Room, after which he told the Secret Service that he wanted to tell the president the “atmosphere was collapsing.”

Gonzalez apparently became the first fence-scaler to cross the 70-yard North Lawn and make it into the White House without being stopped, a failure traced to a string of Secret Service blunders that included a distracted guard-dog officer, an unlocked front mansion door and silenced alarms.

Security weaknesses exposed by Gonzalez’s actions prompted searing criticism of the Secret Service, and the scrutiny added to a string of embarrassments that led to the departure of more than half of the agency’s senior leadership.

Under pressure from lawmakers and new director Joseph P. Clancy, the Secret Service has begun changes including hiring new officers and making the White House fence harder to climb.

Omar J. Gonzalez (New River Valley Regional Jail via Reuters)

Although the sentence was slightly less than the 18 months that federal prosecutors had sought, they said it reflected the crime’s gravity.

“Mr. Gonzalez is now paying the price for his foolish decision to jump the fence and run inside the White House,” Vincent H. Cohen Jr., the acting federal prosecutor for the District, said in a statement. “The prison sentence imposed by the court should deter others from taking actions that needlessly put the First Family and White House employees at risk.”

Cohen’s office had warned that Gonzalez has a history of paranoid delusions in which he has encountered police with multiple weapons and firearms. Without treatment, Gonzalez can be expected to have future problems “with potentially calamitous consequences,” prosecutors David J. Mudd and Thomas A. Gillice, with the national security section of the U.S. attorney’s office for the District, wrote to Collyer last week.

In February 2013, for instance, police responded to a burglary report by Gonzalez and arrived to see him patrolling his front yard in Copperas Cove, Tex., armed with an assault rifle, two handguns, several handgun clips and a knife. Gonzalez said he was being secretly surveilled by cameras in his home and listened to.

Last month in Virginia, Gonzalez pleaded guilty and a judge sentenced him to 15 years in prison, all suspended, and 10 years of supervision on two state felony counts of eluding police while carrying an illegal sawed-off shotgun arising from a July 19 traffic stop on Interstate 81.

Gonzalez said he failed to pull over because he had an “Iraqi moment”: a “flashback” hallucination triggered by the police car’s lights and sirens. He was carrying four high-powered rifles, another pump shotgun, several handguns and other weapons, which were taken by Virginia State Police.

On Aug. 25, Secret Service officers questioned Gonzalez after they saw him carrying a hatchet in the back waistband of his pants along the south fence of the White House.

Then, after his September intrusion, a search of his Ford Bronco parked near the White House found 800 rounds of ammunition, two hatchets and a machete marked “Carnivore,” several tomahawks, and numerous knives.

David W. Bos, an assistant federal public defender, said that Gonzalez was “deeply remorseful” and that his dash into the White House carrying a folding knife with a 3 1/2 -inch blade was an aberration prompted by mental illness and post-traumatic stress disorder, treatment for which his client has been “fully compliant.”

Gonzalez, a decorated Army cavalry scout, had spotless criminal and drug records before his illness last summer.

Gonzalez served in the Army from 1997 to 2003 and from 2005 to 2012, when he was honorably discharged after being diagnosed with PTSD after serving in Iraq, including in Baghdad and Mosul.

Bos said friends and family confirmed that Gonzalez came back a “changed person” after encountering countless firefights with insurgents, roadside bombs, sniper fire and “serious atrocities.” He was homeless and without medication at the time of last summer's incidents.