A Nigerian man pleaded guilty yesterday to attempting to bring down a Christmas Day flight over Detroit with a bomb in his underwear, telling a surprised courtroom that the failed attack was retaliation for the killing of Muslims worldwide.

Umar Farouk Abdulmutallab has never denied the eight charges against him, including conspiracy to commit terrorism and attempted use of a weapon of mass destruction.

Still, he caught observers off guard yesterday when he told the Detroit court that the underwear bomb was a “blessed weapon to save the lives of innocent Muslims.”

He continued his rant, saying, “The United States should be warned that if they continue to persist and promote the blasphemy of Mohammed and the prophets . . . the United States should await a great calamity that will befall them through the hands of the mujahedeen soon.”

Abdulmutallab faces a mandatory sentence of life in prison.

“If you laugh with us now we will laugh with you later on the day of judgment,” he said.

Outside court, defense attorney Anthony Chambers said Abdulmutallab, who had chosen to represent himself and was being assisted by Chambers, pleaded guilty against the lawyer’s wishes.

“We wanted to continue the trial but we respect his decision,” Chambers said.

Abdulmutallab, 25, said he carried a bomb in his underwear onto Northwest Airlines Flight 253 on Christmas Day 2009 with the intention of killing everyone on board.

The bomb didn’t work, and passengers jumped on Abdulmutallab when they saw smoke and fire.

The evidence was stacked high.

Abdulmutallab was badly burned on a plane full of witnesses. The government said he told FBI agents he was working for al Qaeda and directed by Anwar al-Awlaki, the radical, US-born cleric recently killed by the United States in Yemen. There were also photos of his scorched shorts, and video of Abdulmutallab explaining his suicide mission.

“Contrary to what some have claimed, today’s plea removes any doubt that our courts are one of the most effective tools we have to fight terrorism and keep the American people safe,” Attorney General Eric Holder said yesterday in a statement.

“We will continue to be aggressive in our fight against terrorism and those who target us, and we will let results, not rhetoric, guide our actions.”

Passenger Lori Haskell, 34, of Newport, Mich., watched Abdulmutallab’s plea by video in an overflow room. She called his statement “chilling” but not surprising.

“I’m just really relieved that it’s done with,” Haskell said.

Abdulmutallab had written a few court filings in his own hand, including a request to be judged by Islamic law.