Detroit (CNN) -- Umar Farouk AbdulMutallab, the Nigerian man accused of trying to detonate an explosive device in his underwear aboard a flight to Detroit, surprised courtroom officials and spectators on the second day of his trial Wednesday by pleading guilty to all the counts against him.
He previously had pleaded not guilty to the charges, which included attempted use of a weapon of mass destruction, conspiracy to commit an act of terrorism, and possession of a firearm or destructive device in furtherance of an act of violence.
AbdulMutallab acknowledged in a courtroom statement Wednesday that he had previously traveled to Yemen and was "greatly inspired" to participate in such a plot by U.S.-born militant cleric Anwar al-Awlaki, who was killed by a U.S. drone strike in Yemen September 30. U.S. officials say the terror group al Qaeda in the Arabian Peninsula helped foment the bombing attempt.
"I carried with me an explosive device to avenge the killing of innocent Muslims," AbdulMutallab said, adding that the failed plot was in retaliation for "U.S. tyranny and oppression of Muslims."
"I am guilty of this by U.S. law, but not in the Koran," he added. "If you laugh at us now, we will laugh to you later."
The prosecution made its opening statement Tuesday and had already called its first witness in the case.
U.S. District Attorney Barbara McQuade said the case shows the value of civilian courts. "We should not limit ourselves to military tribunals," she said.
The case shows "the world that our system of justice works," McQuade added.
Sentencing will take place on January 12.
AbdulMutallab was a passenger aboard Northwest Airlines Flight 253 en route from the Netherlands to Detroit on Christmas Day 2009 when he attempted the bombing.
Jonathan Tukel, chief of the National Security Unit for the U.S. Attorney's Office in the Eastern District of Michigan, laid out details of the flight in his opening statement.
Pointing to AbdulMutallab, Tukel said, "His sole reason for being on Flight 253 was to kill all of the passengers and himself. He thought he'd end up in heaven."
After taking numerous trips to the bathroom, AbdulMutallab went back to the bathroom about an hour before the plane was to land, "to purify himself to die," Tukel said.
AbdulMutallab did not eat or drink on the plane, a fast that was part of his ritual purification, Tukel said.
A witness testified that AbdulMutallab was in the bathroom for about 15 to 20 minutes, which seemed long to the passenger, Tukel said.
When AbdulMutallab returned to his seat, he pulled a blanket over his head, "pushed the plunger on the bomb and prepared to die," Tukel said.
Passengers heard a loud noise, which sounded like a firecracker, Tukel said.
AbdulMutallab became enveloped in a fireball which then spread to the wall and carpeting of the plane, yet he remained in his seat "expressionless, completely blank," Tukel said.
Four passengers helped subdue him and tried to put out the fire, Tukel said, and AbdulMutallab was escorted up to the first-class section of the plane.
Georgia resident Dimitrios Bessis, a passenger aboard that 2009 flight who was scheduled to testify Wednesday, said he was among the passengers who put out the fire.
Bessis, who used his hat to stamp out the flame, said he thinks AbdulMutallab is "a very confused person that's misguided."
"This nightmare is over for everybody," he added, in reference to the guilty plea.
Tukel said that when a flight attendant asked AbdulMutallab what he had in his pockets, he called it "an explosive device."
AbdulMutallab was very verbal and spoke with many people, Tukel added, including some on the flight and officials once the flight landed.
The prosecution also called its first witness Tuesday, Michael Zantow, who was on the flight one row behind AbdulMutallab.
Zantow, a 20-year veteran of the Army, was among those who tried to restrain the defendant.
Within a minute of the loud sound on the plane, a passenger said to AbdulMutallab, "Hey man, your pants are on fire!" Zantow testified.
The passenger repeated himself two or three times, and AbdulMutallab did not respond, Zantow said.