Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

Nikolas Jacob Cruz took an Uber to get to Marjory Stoneman Douglas High School, where he shot up several classrooms with a high-powered rifle before escaping and managing to evade officers for more than an hour, Florida authorities said Thursday.

Once he was on the loose, Cruz eluded officers long enough to stop by a Walmart and a McDonald's before he was captured and confessed everything, according to law enforcement officials and court documents.

The account was the first detailed picture of one of the nation's deadliest school shootings, in which 17 people were killed and 14 others were wounded.

Cruz, 19, was being held without bond on 17 counts of first-degree premeditated murder in the attack at Douglas High in Parkland, which expelled him last year for disciplinary reasons, according to officials and court documents.

According to a booking affidavit filed Thursday by the Broward County Sheriff's Office: "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. Cruz stated that he brought additional loaded magazines to the school campus and kept them hidden in a backpack until he got on campus to begin his assault."

Photos: Community remembers victims of Florida school shooting

The sheriff's office said he got to the school by ordering a ride from Uber. Deputies tracked down the driver, who said she dropped Cruz off at 2:19 p.m. ET, toward the end of the school day, according to the booking affidavit.

Sheriff Scott Israel told reporters at a news conference Thursday afternoon that the driver didn't know what her passenger was planning and was completely blameless.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Related: Who is Florida school shooting suspect Nikolas Cruz?

Within barely two minutes of being dropped off, Cruz started firing into four classrooms in Building 12, returning to two of them to shoot again, Israel said.

Cruz then went upstairs to the second floor, where he shot one of his victims, before proceeding to the third floor, where he ditched his rifle and backpack, Israel said.

He then ran down the stairs and outside, where he blended in with hundreds of terrified students — many of them his former classmates — and eluded officers as he left campus, Israel said.

Amid the chaos he'd left behind at the school, Cruz made his way to a Walmart store, bought a drink at its Subway restaurant and walked away again, Israel said.

While police and sheriff's deputies frantically looked for him — at least one witness at the school had identified him to arriving investigators, according to the booking affidavit — Cruz went to a McDonald's restaurant, were he lingered for awhile before leaving on foot, Israel said.

It took 40 more minutes for Coconut Creek police to spot and detain Cruz in the nearby community of Coral Springs at about 3:40 p.m., according to the timeline Israel gave.

Contrary to some media reports that Cruz may have been wearing a gas mask or some sort of tactical or bulletproof vest, Israel said he didn't believe that was true.

Related: Football coach Aaron Feis died shielding students

Neither Israel nor the booking affidavit addressed a possible motive. Asked whether Cruz was associated with the white nationalist movement, Israel said, "It's not confirmed at this time."

Robert Lasky, special agent in charge of the FBI's Miami office, confirmed reports that the FBI's field office in Jackson, Mississippi, received a tip on Sept. 25 about a comment that had been posted to a YouTube account by someone with the username "nikolas cruz": "Im going to be a professional school shooter."

The comment was first reported by BuzzFeed News.

Lasky said that the comment — which YouTube later removed — offered no other information and that the FBI was unable to positively identify the commenter or to establish a link to South Florida at the time.

Israel and Lasky also didn't go into detail about social media postings, presumably made by Cruz, that the FBI said it was reviewing. Israel on Wednesday described the postings as "very disturbing."

Related: Social media changed what the public sees and hears during school shootings

Israel asked for patience Thursday, saying local, state and federal investigators had already interviewed more than 2,000 people.

"It's going to take a lot of time to sift through what was true, what was accurate and what's not," he said.