He will face a mandatory minimum sentence of 10 years in prison.
Ortega-Hernandez also pleaded guilty to two counts of injuring a dwelling in the U.S. and using a firearm during a crime of violence. Under the plea agreement, the United States dismissed 17 separate charges in the original indictment against him.
Prosecutors held that Ortega-Hernandez purchased and used a Romanian Cugir SA semi-automatic assault-style rifle to fire at least eight rounds at the south side of the White House in November, 2011.
President Obama and the first lady were traveling in California and were not in the White House at the time of the shooting.
Earlier that year, before driving to Washington, D.C., Ortega-Hernandez made two videos in Idaho, praising the former head of al Qaeda, Osama bin Laden, for “having the courage to stand up to the United States,” the government said.
Ortega-Hernandez also called for a revolution against the federal government and described himself as a “cold-hearted warrior of God,” declaring that, “it’s time for Armageddon,” according to the Justice Department.
U.S. Attorney Ronald Machen lauded the government’s case against Ortega-Hernandez on Wednesday, calling attention to the shooting earlier this week at the Washington Navy Yard that killed 13 people, including the alleged gunman.
“Firing an assault rifle at the White House to make a political statement is terrorism, plain and simple,” said Machen in a statement.
“As we have seen this week, gunmen who come to the nation’s capital bent on violence can inflict terrible damage. This act of cowardice put lives at risk. Today’s plea demonstrates that those who come to the District of Columbia, planning to use violence to send a message, should expect to spend decades behind bars.”