An orphaned 19-year-old who participated in paramilitary drills with a white nationalist group has been charged with murder over the deaths of 17 people who were shot at a Florida high school.
Nikolas Cruz legally purchased the AR-15 rifle used in the assault at Marjory Stoneman Douglas High School, law enforcement officials said.
A Florida judge ordered that the suspect be held without bail on 17 counts of murder.
Cruz was wearing an orange jumpsuit with his hands cuffed at his waist during the Thursday afternoon hearing.
His lawyer did not contest the order and had her arm around Cruz during the brief court appearance.
Cruz confessed to carrying out one of the nation's deadliest school shootings and concealing extra ammunition in his backpack, according to a sheriff's department report.
The report from the Broward County Sheriff's Office said Cruz told investigators that he shot students in the hallways and on the grounds of the school, which has 3,000 students.
Cruz told officers he brought more loaded magazines to the school and kept them hidden in the backpack until he got on campus.
As students began to flee, he said, he decided to discard his AR-15 rifle and a vest he was wearing so he could blend in with the crowd.
As the criminal case against the suspect took shape, the leader of a white nationalist militia called the Republic of Florida said Cruz was a member of his group and participated in exercises in Tallahassee.
Jordan Jereb said he did not know Cruz personally and that "he acted on his own behalf" and is "solely responsible for what he just did".
The group wants Florida to become its own white ethno-state.
Mr Jereb said his organisation holds "spontaneous random demonstrations" and tries not to participate in the modern world.
He also said Cruz had "trouble with a girl" and that he believed the timing of the attack, on Valentine's Day, was not a coincidence.
In a national address from the White House, President Donald Trump said he wanted America's children to know: "You are never alone, and you never will be."
He planned to travel to Florida to meet victims' families, explore how to better secure schools and to "tackle the difficult issue of mental health".
At no point did Mr Trump mention guns or how to control them.
Former president Barack Obama called for "common-sense gun safety laws", tweeting: "We are grieving with Parkland. But we are not powerless. Caring for our kids is our first job."
He added: "And until we can honestly say that we're doing enough to keep them safe from harm, including long overdue, common-sense gun safety laws that most Americans want, then we have to change."
The former Democratic president held office through multiple mass shootings.
He pushed to tighten access to firearms but was blocked by the Republican-controlled Congress.
Thirteen wounded survivors were taken to hospital, including two people in critical condition.
Some bodies remained inside the school on Thursday as authorities investigate the crime scene, the sheriff said.
The killed included a school sports director and another adult who worked as a monitor at the school.
Automatic gunfire can be heard as a gunman roams a Florida high school pic.twitter.com/qFJEgkzK0R— Sky News (@SkyNews) February 15, 2018
It was the nation's deadliest school shooting since a gunman attacked a primary school in Newtown, Connecticut, in 2012.
The overall death toll differs by how such shootings are defined, but Everytown For Gun Safety has tallied 291 school shootings in America since 2013, and this attack makes 18 so far this year.
Cruz legally purchased the AR-15 used in the attack about a year ago, law enforcement officials said.
Federal law allows people 18 and older to legally purchase long guns, including this kind of assault weapon.
FBI agent Rob Lasky said the agency investigated a 2017 YouTube comment posted with the screen name Nikolas Cruz that said: "I'm going to be a professional school shooter."
Mr Lasky said the FBI did a database review, but could not determine the time or location of the post, or the true identity of the person making the comment.
Ben Bennight, whose YouTube username is BenTheBondsman, posted a video on Wednesday saying he had spotted the comment on September 24, took a screenshot, flagged it for YouTube and called an FBI office in Mississippi to report it.
He said two FBI agents visited him the next day.
"I knew that I couldn't just ignore that," Mr Bennight said.
The FBI called him again on Wednesday within about two hours of the shooting, and one agent interviewed him in person, he said.
"Basically they're going to have to get with YouTube about where the comment originated, but I think they already know," he said.
Authorities offered no immediate details about a possible motive, except to say that Cruz had been kicked out of the high school.
Students who knew him described a volatile teenager whose strange behaviour had caused others to end friendships with him.
Cruz's mother, Lynda Cruz, died of pneumonia on November 1, neighbours, friends and family members said, according to the Sun Sentinel.
Ms Cruz and her husband, who died of a heart attack several years ago, adopted Nikolas and his biological brother, Zachary, after the couple moved from Long Island in New York to Broward County.
The boys were left in the care of a family friend after their mother died, said family member Barbara Kumbatovich, of Long Island.
Unhappy there, Nikolas Cruz asked to move in with a friend's family in north-west Broward County.
That family agreed, and Cruz moved in around Thanksgiving.
According to the family's lawyer, who did not identify them, they knew that Cruz owned the AR-15 but made him keep it locked up in a cabinet. He did have the key, however.
Lawyer Jim Lewis said the family is co-operating with authorities and had no idea he was planning the shooting.
He seemed like "just a mildly troubled kid who'd lost his mom" during the three months they lived together, Mr Lewis said.
Photos posted on an Instagram account linked to Cruz show half a dozen weapons displayed on a mattress and a box of ammunition.
Victoria Olvera, 17, said Cruz was expelled in the last school year because he got into a fight with his ex-girlfriend's new boyfriend.
She said he had been abusive to the girl.
"I think everyone had in their minds if anybody was going to do it, it was going to be him," said Dakota Mutchler, also 17.