Following the bombing of an American military installation in the Middle East (the film shows footage from the 1996 Khobar Towers bombing), the U.S. government orchestrates the capture of the mastermind believed to be behind the attack, Sheikh Ahmed bin Talal. In New York City FBI Special Agent Anthony Hubbard (Washington) and his Lebanese-American partner Frank Haddad (Shalhoub) are told of a hijacked bus, fully loaded with passengers and containing an explosive device. The bomb turns out to be a paint bomb and the terrorists manage to escape. The FBI receives demands to release the sheikh.
Hubbard eventually comes into conflict with CIA agent Elise Kraft (Bening). Hubbard takes a terrorist suspect into custody and arrests Kraft. Afterwards another terrorist threat is made and an MTA bus is bombed, though the children on-board are permitted to leave before the bus is destroyed. When the FBI captures a person of interest named Samir Nazhde he admits to signing the visa application of one of the suicide bombers in the course of signing many applications for student visas in his job as a lecturer. However, Kraft insists that Samir is not a terrorist and that his continued freedom is vital to the investigation.
The FBI eventually identifies and storms a safehouse belonging to terrorists who are associated with the bombings. However, days later, new terror cells launch more devastating attacks, starting with the bombing of the New Victory Theater in Times Square during an evening performance. This is followed days later by a hostage situation at an elementary school (which is resolved when Hubbard shoots the hostage taker). Shortly after this, a suicide bomber drives a van full of explosives into the lobby of 1 Federal Plaza, the location of the FBI's New York City field office, resulting in over 600 fatalities.
In spite of objections, the President of the United States declares martial law and armored vehicles and elements of the U.S. Army's 82nd and 101st Airborne Divisions, under Major General William Devereaux (Willis), occupies and seals off Brooklyn in an effort to find the remaining terrorist cells. Subsequently all young males of Arab descent, including Haddad's son Frank, Jr., are rounded up and detained in Downing Stadium. Haddad resigns in protest. New Yorkers stage violent demonstrations against the army and the racial profiling of the Arabs and the Army fights to maintain control. There are reports of Army killings. When pressed by the White House Chief of Staff (Chip Zien) if the United States is holding the Sheikh, General Devereaux denies it.
Hubbard and Kraft, now revealed to be an agent named Sharon Bridger, continue their investigation and capture a suspect, Tariq Husseini. Using torture, Devereaux shoots and kills Husseini (off screen) in the course of the interrogation. Afterward, Bridger tells Hubbard that Husseini knew nothing of value because of the principle of compartmentalized information and, sickened, she finally tells Hubbard what she knows. It is revealed that she herself provided training and support to rebels opposed to Saddam Hussein's regime, working with Samir to recruit and train the followers of the Sheikh. After the United States cut their funding and left them exposed, she took pity on the few of them who had not yet been slaughtered by Hussein's forces, and arranged for them to escape to the United States, ultimately leading to the present situation as they turn their covert and bomb making skills on the country that now holds their Sheikh. She and Hubbard compel Samir to arrange a meeting with the final terrorist cell. In a discreet meeting with the White House Chief of Staff Hubbard is finally informed of the Sheikh's apprehension, which was carried out at General Devereaux's personal initiative. Hubbard convinces Haddad that he needs his help, and Haddad returns to the FBI.
A multi-ethnic peace march demonstrates against the occupation of Brooklyn. As the march is getting under way Hubbard and Haddad arrive at the meeting place, but Bridger and Samir have already left. Samir reveals to Bridger that he constitutes the final cell while in another sense he says, "there will never be a last cell." He straps a bomb to his body which he intends to detonate among the marchers. Hubbard and Haddad arrive in time to stop him from leaving, but Samir shoots Bridger in the heart as she struggles to stop him. Hubbard kills Samir, but despite their best efforts he and Haddad can only watch as Bridger succumbs to her wounds after managing to recite certain lines of the second half of The Lord's Prayer and concluding with "Insha'Allah" â the Arabic phrase "God Willing."
Hubbard, Haddad, and other FBI agents raid Devereaux's headquarters to arrest him for the torture and murder of Husseini, as well as his role in kidnapping the Sheikh in violation of the Logan Act. Devereaux insists that under the War Powers Resolution the authority vested in him by the President supersedes that of the court which issued the arrest warrant. He then commands his soldiers to aim their guns at the agents, resulting in a tense standoff. Hubbard reminds Devereaux that the civil liberties and human rights which he took from Husseini are what all his predecessors have fought and died for. Devereaux finally submits and is arrested. Martial law ends, and the detainees, including Haddad's son, are freed.

Question: When does martial law end?
Answer: Masjor General William Devereaux give up and is arrested.
Alternative answer: After Devereaux surrenders.