The suspect, James Holmes, 24, told the police after his arrest that he had booby-trapped his Aurora apartment with explosive devices, leading the police to evacuate five buildings in the neighborhood as they sought to disable what they described as “incendiary and chemical devices” that appeared to be rigged to trip wires.
“We have an active and difficult scene,” said Aurora’s police chief, Dan Oates. “It may be resolved in hours or days. We simply don’t know how we’re going to handle that.”
During the attack, witnesses said, Mr. Holmes entered through a side door of the packed theater wearing a gas mask. He set off two smoke devices before firing randomly at audience members, who had just settled into their seats. Within minutes, he was arrested in a parking lot behind the theater near his car, the police said.
Mr. Holmes had apparently planned the attack for some time. In addition to the gas mask, he wore body armor and a helmet and was dressed completely in black. His gear included a throat protector, a groin protector, a bulletproof vest and leggings, and tactical gloves.
He entered the theater with an AR-15 assault rifle, a Remington 12-gauge shotgun and a .40-caliber Glock handgun. A fourth gun, another Glock pistol, was found in his car. “This is the act, apparently, of a very deranged mind,” said Gov. John Hickenlooper of Colorado.
A federal law enforcement official said investigators knew where at least two of the guns had been purchased, and suggested that they were bought recently, but would not say where or precisely when. Another law enforcement official said that information investigators had obtained about the purchase of the AR-15 rifle indicates that it was bought locally and apparently legally, as were the other guns, adding, “there’s nothing nefarious there.”
The suspect was in possession of a clip with more than 20 rounds, a federal official said, that would have been illegal under an assault rifle ban that expired in 2004. The Bureau of Alcohol, Tobacco, Firearms and Explosives has handed over information on where and when the guns were purchased to the police in Aurora. Investigators have uncovered no solid indications of a motive and no evidence of any past aberrant behavior.
“He’s not on anybody’s radar screen — nothing,” the law enforcement official said, adding that investigators were sifting through social media sites in an effort to determine whether Mr. Holmes had ever posted anything that might indicate some violent tendencies. The second law enforcement official, speaking of Mr. Holmes, said: “This guy is somewhat of an enigma. Nobody knows anything about him.”
The shooting took place at the midnight showing of “The Dark Knight Rises,” in a theater packed with families and children. It was not immediately clear whether the gunman ran out of ammunition or stopped shooting for some other reason.
Commissioner Raymond W. Kelly of the New York City police, who dispatched officers to patrol screenings of the film in New York, said he had been told the shooting suspect had hair painted red and said he was the Joker. That detail could not be initially confirmed. The authorities believe that Mr. Holmes acted alone, and that the death toll may increase because some of the wounds were serious.
Mr. Holmes’s family in San Diego asked for privacy in a statement released by the city’s Police Department.
“Our hearts go out to those who were involved in this tragedy and to the families and friends of those involved,” the statement said. “We ask that the media respect our privacy during this difficult time. Our family is cooperating with authorities in both San Diego, California and Aurora, Colorado. We are still trying to process this information and we appreciate that people will respect our privacy.”
Mr. Holmes’s only criminal history is a traffic summons, the authorities said. He earned a bachelor’s degree with honors in neuroscience in 2010 from the University of California, Riverside, and was a graduate student in neurosciences at the University of Colorado at Denver’s Anschutz Medical Campus, although the university said in a statement that he was in the process of withdrawing. He was collecting unemployment, a federal law enforcement official said.
A spokeswoman for the university, Jackie Brinkman, said that Mr. Holmes was dropping out because of academic problems. Ms. Brinkman said the university was unaware of any incidents with the campus police or disciplinary problems involving Mr. Holmes while he was enrolled.
Billy Kromka, a pre-med student at the University of Colorado, Boulder, worked with Mr. Holmes for three months last summer as a research assistant in a lab of at the Anschutz Medical Campus. Mr. Kromka said he was surprised to learn Mr. Holmes was the shooting suspect. “It was just shocking, because there was no way I thought he could have the capacity to do commit an atrocity like this,” he said.
Mr. Kromka said that Mr. Holmes was one of the quieter people in the lab. He spent much of his time immersed in the computer, often participating in role-playing online games. 
Mr. Kromka said that he never heard Mr. Holmes talk about a girlfriend or his life outside of work.  The police and witnesses described a scene of utter chaos inside the darkened, smoke-filled theater as bullets resounded loudly and people who had gone to see a PG-13-rated action movie were suddenly forced to scramble for cover as friends and loved ones were felled around them.
Chief Oates said he did not know how many shots the gunman had fired, saying only that it was “many, many rounds,” one of which passed through a wall and wounded a moviegoer in an adjoining theater. Jordan Crofter, 19, said he had felt lucky to have snagged a seat in the front row at the midnight screening. But about five minutes into the movie, he said, a side door swung open and a man in black wearing a gas mask calmly strode through.
At first, Mr. Crofter thought perhaps the man was part of the show. But within a few seconds, he said, the man hurled two gas canisters down the theater aisle.
“He walked in so casually, like he knew what he was doing,” said Mr. Crofter. “I heard two pops. Everyone was distracted. That was when the panic and the chaos started.”
Mr. Crofter said that once he noticed that the man was also carrying a rifle, he ran in the opposite direction as fast as he could.
“He started shooting, and everyone ducked and started screaming,” he said. “He looked like he was ready to go into battle. It was like he was walking around and having fun. Emotionless.”
With the investigation in its earliest stages, the authorities said they were unsure what prompted the attack, or whether Mr. Holmes had ties to any hate groups.
Mr. Holmes did tell the police that he had explosives at an Aurora residence, which led F.B.I. agents, along with agents from the Bureau of Alcohol, Tobacco, Firearms and Explosives and the local police to cordon off a North Aurora neighborhood, focusing attention on a third-floor apartment in a red brick building.
Emergency crews perched on a cherry picker were seen breaking the window with an ax.
The police described the apartment as being full of wires and what appeared to be explosive devices.
“It’s something I’ve never seen before,” said Chief Oates.
John Priest, who lives in an adjacent building, said that his 21-year-old son had been in the movie theater with two friends during the shooting but was unharmed. The two friends, however, had been wounded — one was hit by a bullet in the buttocks and grazed in the leg, and the other was shot in the leg. Neither injury is life threatening, he said.
“How could people do something like this?” Mr. Priest said. “I don’t understand this.”
Aurora, which has a population of about 325,000, had only six killings in all of 2011, according to F.B.I. crime data.
At Gateway High School, where the authorities have directed people to gather to get news about friends and family members, Rosemary Ratcliff said that she had so far been unable to find her son, Abdullah, 17, who she believes had been at the midnight screening.
“I haven’t heard from him, and none of his friends are picking up their phones,” she said in a near-whisper as she left the school.
The authorities have not released the names of the victims, but Pentagon officials said that two airmen and one sailor had been wounded in the shooting and that another sailor known to have been at the theater was still unaccounted for.  The Pentagon also said that the suspect was not a past or current member of the armed forces.
The wounded were sent to six hospitals in the region, including Children’s Hospital Colorado and the University of Colorado Hospital.
“The entire emergency department staff was called in,” said Dr. Comilla Sasson, who added that even though the emergency room was full before the shooting, it had admitted 20 victims who ranged in age from 3 months to 45 years. The victims’ injuries included gunshot wounds and shrapnel injuries, Dr. Sasson said. Nine people were in critical condition.
At least three other people were in critical condition at other hospitals, officials said.
The shooting erupted at the Century 16 Movie Theater during the first showings of “The Dark Knight Rises.” Throngs had gathered, some dressed as characters from the highly anticipated Batman sequel. The four screenings of the film were sold out, although it is not quite clear how many people were inside at the time.
The police and witnesses said that after the gunman entered the theater through an exit door there was the smell of either pepper spray or tear gas in the theater as gunshots rang out.
Jamie Rohrs, 25, was at the theater with his family, including his 4-month-old toddler, Ethan, whom Mr. Rohrs held during the movie. A few minutes into the film, he said that he saw a flash.
“You didn’t know if it was fireworks or what it was,” he said. “My first instinct was to get to the ground, get to the ground. I ducked. That was the first moment you knew something was going on.”
Mr. Rohrs said that he jumped over his seat and crouched into the next row, his baby still in his arms.
 “It was just chaos. You started hearing screaming. You looked up and people were falling. It was like a dream,” he said. “I was thinking, Do I lay him down? Do I play dead? If there is more than one gunman, is he going to go upstairs and shoot? Ethan’s crying. And we’re just laying there.”
 Mr. Rohrs said he was stumbling and crawling through the theater, trying to figure out what to do.
 “Do I run out the door? Is he going to shoot the baby? What am I to do?” he said, his voice quavering. “I didn’t drop the baby. I fell on my arms.”
Finally, he said, he stood up to look for a way out and was able to escape as gunshots flashed to his right.
President Obama, in Florida as part of a campaign swing, was notified of the shooting by his top counterterrorism adviser, John O. Brennan, at 5:26 a.m., the White House said.
“We do not believe at this point there was an apparent nexus to terrorism,” Jay Carney, the White House press secretary, told reporters on Air Force One. Mr. Obama returned to Washington on Friday afternoon, cutting short his Florida trip, his campaign said.In remarks at a previously scheduled stop in Fort Myers, Fla., Mr. Obama talked in highly personal ways about the tragedy. “My daughters go to the movies,” he said. “What if Malia and Sasha had been in the theater as so many of our kids do every day? Michelle and I will be fortunate enough to hug our girls a little tighter tonight.”He reflected on the fragility of life and the triviality of so much of what passes for daily existence, calling on the country to remember what really matters. “The people we lost in Aurora loved and were loved,” he said. “They were mothers and fathers, they were husbands and wives, sisters and brothers, sons and daughters, friends and neighbors. They had hopes for the future and they had dreams that were not yet fulfilled.”
He asked for a moment of silence and asked the Florida crowd to “spend a little time thinking about the incredible blessings that God has given us.”
Both Mr. Obama and Mitt Romney, the presumed Republican presidential nominee, said that they planned to pull television campaign ads in Colorado.
The movie studio Warner Bros., which is owned by Time Warner, released a statement Friday morning saying that the company and the filmmakers were “deeply saddened” and “extend our sincere sympathies to the families and loved ones of the victims at this tragic time.”
According to a Warner Bros. spokeswoman, the studio pulled its trailer for an upcoming film, “Gangster Squad,” which is set for release in September. In the trailer, which was shown at some screenings of “The Dark Knight Rises,” but not in the Aurora theater, men are seen shooting up the crowd in a movie theater.
Mr. Kelly said he had stepped up security at all 40 locations in New York City where the film is playing. “A lot of young people are going to see this movie,” he said.
Mayor Michael R. Bloomberg of New York, who has waged a national campaign for stricter gun laws, called on President Obama and Mr. Romney to address more concretely the issue of gun violence in their campaigns.
“You know, soothing words are nice,” Mr. Bloomberg said during his weekly radio program, “but maybe it’s time that the two people who want to be president of the United States stand up and tell us what they are going to do about it, because this is obviously a problem across the country.”

Dan Frosch reported from Aurora, William K. Rashbaum and Timothy Williams from New York, and Michael S. Schmidt from Washington. Reporting was contributed by Peter Baker from West Palm Beach, Fla.; Jennifer Medina and Michael Cieply from Los Angeles, Elisabeth Bumiller, Jennifer Steinhauer and John Cushman from Washington; and J. David Goodman, Victoria Shannon, Emma G. Fitzsimmons, Jennifer Preston, Wendy Ruderman and Thomas Kaplan from New York. Kitty Bennett and Sheelagh McNeill contributed research.