Image caption "Muslims don't abide by human laws," Shahzad said in court

The man convicted of an attempted car bomb attack in New York's Times Square has been sentenced to life in prison.

Faisal Shahzad, a Pakistani-born US citizen, pleaded guilty in June to 10 weapons and terrorism charges.

At his sentencing in Manhattan, Shahzad told the judge "war with the Muslims has just begun", with the US facing "imminent" defeat.

Explosives packed into the vehicle on 1 May failed to detonate and Shahzad was arrested two days later.

"Faisal Shahzad is a remorseless terrorist who betrayed his adopted country and today was rightly sentenced to spend the rest of his life in federal prison," US Attorney Preet Bharara said in a statement after the sentencing.

In the courtroom in lower Manhattan on Tuesday, about 2.5 miles (4km) south of Times Square, Shahzad warned Americans to "brace themselves" for a war with Islam.

"We don't accept your democracy or your freedom," he said, adding that he rejected the court's authority because "Muslims don't abide by human laws".

Giving Shahzad a mandatory life sentence, Judge Miriam Cedarbaum said it was important "to protect the public from further crimes of this defendant and others who would seek to follow him".

She asked if he had sworn allegiance to the US when he took the oath of citizenship in April last year.

At the scene Faisal Shahzad wore dark blue prison-issued trousers and a tunic with a white knitted skullcap, his curly hair poking out below his ears when he entered the courtroom. His bearded face was serious and inscrutable, but his tone was oddly casual as he gave a defiant statement. In perfect but slightly accented English, Shahzad spoke in terms of Islamic jihadism, railing against the wars in Iraq and Afghanistan, but also the "slave country" of Pakistan. Judge Miriam Cedarbaum appeared unflappable, if slightly disdainful. She worked with business-like efficiency, wasting little time. The swift proceedings were over in less than 30 minutes. Shahzad, handcuffed, was led out of the courtroom, his head held high.

"I did swear but I did not mean it," Shahzad replied.

But Shahzad showed little affection for his native country of Pakistan, calling it a "slave country", the BBC's Katie Connolly in New York says.

Shahzad also likened US forces in Iraq and Afghanistan to "crusaders" and said the Koran gave Muslims the right to defend themselves, our correspondent says.

Experts say the petrol and fertiliser-fueled bomb Shahzad left in Times Square fizzled and failed to go off because the wiring was faulty and it contained the wrong ingredients.

"Had the bombing played out as Shahzad had so carefully planned, the lives of numerous residents and visitors of the city would have been lost and countless others would have been forever traumatised," prosecutors wrote in court papers ahead of the sentencing at Manhattan Federal Court.

A street vendor in Times Square - which was packed with visitors - alerted police after seeing smoke coming from the Nissan Pathfinder vehicle.

However, a videotaped FBI reconstruction of an identical bomb showed it producing a fireball that ripped the vehicle in two, destroyed others around it, and sent debris hundreds of feet in all directions.

'Second bomb'

"While it is impossible to calculate precisely the impact of Shahzad's bomb had it detonated, the controlled detonation... demonstrated that those effects would have been devastating to the surrounding area," prosecutors wrote.

The prosecution also alleged that Shahzad had planned to detonate a second bomb two weeks later.

At his court appearance in June, Shahzad said he wanted "to plead guilty and 100 times more".

He said he wanted the US to know that if it did not leave Iraq and Afghanistan, "we will be attacking US".

"One has to understand where I'm coming from. I consider myself... a Muslim soldier," he said.

Shahzad was arrested as he tried to take a flight to Dubai from New York's John F Kennedy airport.

Under interrogation, the financial analyst said he had gone to Pakistan's North Waziristan tribal region in December 2009 for bomb training with militants linked to the Pakistani Taliban, his indictment read.

He is also said to have received about $5,000 (£3,160) in cash from a co-conspirator in Pakistan, who he understood worked for the Taliban.