The teenager accused of killing 17 people at a Florida high school on Wednesday has confessed to the shooting, police say.
Nikolas Cruz, 19, said he arrived on campus and began shooting students before abandoning his weapon and escaping, according to a court document.
He has appeared in court charged with 17 counts of premeditated murder.
The FBI has admitted it received a tip-off about him last year.
The attack, at Marjory Stoneman Douglas High School in Parkland, Florida, is the deadliest US school shooting since 2012.
“Cruz stated that he was the gunman who entered the school campus armed with a AR-15 and began shooting students that he saw in the hallways and on the school grounds,” according to the court document.
He said he was carrying extra ammunition in a black duffel bag and backpack, it said.
Mr Cruz then discarded his weapon in an attempt to blend in and escape, the documents showed.
He was reportedly able to flee the scene undetected before entering a Walmart and then a McDonalds, and was eventually spotted by police and arrested one hour after the attack.
What do we know about the suspect?
Mr Cruz had been expelled from the school he has confessed to attacking and some students said they had joked “he’s the one to shoot up the school”.
One former schoolmate, Chad Reuters, told Reuters Mr Cruz was an “outcast” who was “crazy about guns”.
His interest in weapons was apparent on his social media profiles, which Broward County Sheriff Scott Israel said were “very, very disturbing”.
Two separate Instagram accounts, now deleted, purport to show Mr Cruz posing with guns and knives.
What were the warnings?
After seeing a comment on a YouTube post last year by Mr Cruz, user Ben Bennight contacted the FBI and spoke to representatives for about 20 minutes.
Mr Bennight said the FBI contacted him again following the school shooting in Parkland.
The FBI confirmed on Thursday that they were made aware of the comment, adding that they had conducted “checks” but were unable to identify the person behind it.
Meanwhile, maths teacher Jim Gard told the Miami Herald that school authorities had emailed teachers about Mr Cruz’s behavioural problems.
“There were problems with him last year threatening students, and I guess he was asked to leave campus,” he said.