The bomb, which was in a van parked off Pioneer Courthouse Square, was a fake ? planted by F.B.I. agents as part of the elaborate sting ? but ?the threat was very real,? Arthur Balizan, the F.B.I.?s special agent in charge in Oregon, said in a statement released by the Department of Justice. An estimated 10,000 people were at the ceremony on Friday night, the Portland police said.

Mr. Balizan identified the suspect as Mohamed Osman Mohamud, 19, a naturalized United States citizen. He graduated from Westview High School in Beaverton, Ore., a Portland suburb, and had been taking classes at Oregon State in Corvallis until Oct. 6, the university said on Saturday.

Mr. Mohamud was charged with trying to use a weapon of mass destruction. ?Our investigation shows that Mohamud was absolutely committed to carrying out an attack on a very grand scale,? Mr. Balizan said.

?At the same time, I want to reassure the people of this community that, at every turn, we denied him the ability to actually carry out the attack,? he added.

The terrorism attempt was the latest is a string of plots since last year involving Americans or immigrants who had become radicalized, often through exposure to extremist Web sites. In May, a Pakistani-born American was arrested in the plotting of a car bomb attack in Times Square, and later pleaded guilty.

But in contrast to that plan, which the authorities learned about only at the last minute, the F.B.I. had been tracking Mr. Mohamud since 2009 and his planning unfolded under the scrutiny and even assistance of undercover agents, officials said.

The authorities arrested Mr. Mohamud 20 minutes before the tree-lighting ceremony started. As he was taken into custody, he kicked and screamed at the agents and yelled, ?Allahu akbar!? an Arabic phrase meaning ?God is great,? the authorities said.

Federal agents said that Mr. Mohamud thought Portland would be a good target because Americans ?don?t see it as a place where anything will happen.?

?It?s in Oregon; and Oregon, like you know, nobody ever thinks about it,? an affidavit quotes him as saying.

The F.B.I.?s surveillance started in August 2009 after agents intercepted his e-mail messages with a man he had met in Oregon who had returned to the Middle East, according to a law enforcement official who described the man as a recruiter for terrorism. According to the affidavit, the man had moved to Yemen and then northwest Pakistan, a center of terrorist activity.

Mr. Mohamud was then placed on a watch list and stopped at the Portland airport in June 2010 when he tried to fly to Alaska for a summer job.

Later in June, aware of Mr. Mohamud?s frustrated attempts to receive training as a jihadist overseas, an undercover agent first made contact with him, posing as an associate of the man in Pakistan. On the morning of July 30, the F.B.I. first met with Mr. Mohamud in person to initiate the sting operation.

The planning for the attack evolved from there, with Mr. Mohamud taking an aggressive role, insisting that he wanted to cause many deaths and selecting the Christmas target, according to federal agents. Reminded that many children and families would be at the ceremony, Mr. Mohamud said that he was looking for ?a huge mass? of victims, according to the F.B.I.

He had been dreaming of committing an act of terrorism for four years, Mr. Mohamud told undercover agents: ?Since I was 15 I thought about all this things before.?

One of the unknowns in the case is the precise role of the unnamed man with whom Mr. Mohamud exchanged the intercepted e-mails. According to the affidavit, the man was a student in the United States from August 2007 to July 2008. At some point, while Mr. Mohamud was still in high school, the two met. In his initial meetings with the undercover agents, Mr. Mohamud described his dreams of joining the jihadist cause, and mentioned articles he had written on the subject.

Mr. Mohamud told the agents that in 2009 he had published three articles on the Web site Jihad Recollections, which was edited by a Saudi-born American, Samir Khan, from a home in North Carolina. Mr. Khan moved to Yemen, where he runs Inspire, an English-language Web site, on behalf of Al Qaeda in the Arabian Peninsula.

One of Mr. Mohamud?s articles was titled ?Getting in Shape Without Weights? and described the need to ?exercise the body and prepare it for war.?

It was not clear on Saturday whether Mr. Mohamud has yet obtained counsel.

Colin Miner reported from Portland, Ore., and Liz Robbins and Erik Eckholm from New York. William Yardley contributed reporting from Beaverton, Ore., Beth Slovic from Portland and Eric Schmitt, Scott Shane and Edward Wyatt from Washington.