A Maryland man pleaded guilty Thursday to trying to detonate what he thought was a car bomb outside a military recruiting center in suburban Baltimore, saying he was motivated by what he saw as an American war on Islam.

Antonio Martinez entered the plea to the charge of attempting to use a weapon of mass destruction against federal property. The plot to bomb the Armed Forces Recruiting Center in Catonsville in December 2010 was foiled by an FBI sting.

The 22-year-old had also faced a charge of trying to kill U.S. officers and employees, but prosecutors agreed to drop the second charge at sentencing. The deal calls for a 25-year prison term.

Martinez wore a burgundy jumpsuit and his hair in two braids in court, and he smiled and hugged his defense attorney. The U.S. citizen born who was born abroad preferred to be called Muhammad Hussain after his conversion to Islam and signed the plea using both names.

Public records are unclear about when Martinez, who was born to a Nicaraguan father and an African-American mother, moved to Maryland, but he attended Laurel High School in Prince George's County, a Washington suburb. The former part-time construction worker said in court Thursday that he finished 10th grade.

In the plea agreement, Martinez acknowledges that he wanted to pursue jihad to the United States "to send a message that all American soldiers would be killed so long as the country continued its 'war' against Islam."

An FBI informant first communicated with Martinez on Facebook after seeing public posts "espousing his extremist views" and recognizing him from a mosque he attended, according to court documents. The documents say Martinez later told the informant of his ideas for attacking military-linked sites and said all he thought about was jihad.

Authorities say Martinez' ideas ranged from a bombing and armed attack to burning the building down. He told an undercover FBI agent that he wanted to make jihadist activities his profession, dedicating his life to the cause, according to the plea.

Martinez decided on a car bomb after a discussion with the undercover agent because "using a bomb would allow him to commit further acts here and overseas," prosecutor Christine Manuelian said.

The informant and the undercover agent gave Martinez repeated opportunities to back out, but he insisted he was committed, even after expressing reservations after a Somali-born teenager was arrested in Oregon in a similar sting, according to court documents.

Just days before the planned attack, Martinez told the informant that he was "ready ... happy, anxious, just ready." Asked if he felt like someone was pushing him, Martinez replied, "I came to you about this, brother," according to the plea.

On the way to the recruiting center, Martinez had the informant record a video statement in which he said he and others would continue the fight until those who waged a war on Islam stopped, according to the plea. He then armed the fake bomb on his own, parked the SUV in front of building and went to vantage point and waited to press the button until the undercover agent told him there were several soldiers in the building, Manuelian said. He was arrested within seconds, she said.

After his arrest, Martinez confessed that the attack was his idea, he wanted to be a martyr and he had expected an explosion that would level the front of the building, according to the plea.

After the hearing, FBI Special Agent in Charge Richard McFeely thanked members of the Muslim community for reaching out to law enforcement and identifying a threat.

The case illustrates the Department of Justice's approach since the Sept. 11, 2001, attacks, trying to stop catch suspects before they can carry out schemes while protecting liberties, according to U.S. Attorney for Maryland Rod Rosenstein.