Cruz was arrested without incident in the nearby town of Coral Springs after the Valentine's Day rampage and taken to hospital with minor injuries, the sheriff said.
People are brought out of Marjory Stoneman Douglas High School after a shooting at the Florida school.
School shooting in Florida.
Medical personnel tend to a victim following a shooting at Marjory Stoneman Douglas High School in Parkland.
"We have already begun to dissect his websites and things on social media that he was on and some of the things ... are very, very disturbing," Sheriff Israel said.
"He had countless magazines, multiple magazines, and at this point, we believe he had one AR-15 rifle."
"This is a terrible day for Parkland," Sheriff Israel said, speaking of the city of about 30,000 people, located 80 kilometres north of Miami.
"My very own triplets went to that school."
A teacher at the school told the Miami Herald Cruz had been identified previously as a potential threat to his classmates.
"We were told last year that he wasn't allowed on campus with a backpack on him," math teacher Jim Gard said. "There were problems with him last year threatening students, and I guess he was asked to leave campus."
Following the shooting, hospitals across Broward County received 17 patients with three remaining in critical condition.
Broward County Public Schools Superintendent Robert Runcie was horrified following the shooting.
"Just a horrible day for us," Supt Runcie said, adding the incident appeared to be over.
"This is a very tragic situation for everybody involved," Parkland Mayor Christine Hunschofsky told CNN, adding she had spoken to a number of students.
"They were very scared. And almost in shock when they came out."
Asked about security, the mayor said a police officer is always stationed at the school and there was a "single point of entry".
Immediately after the shooting live television showed dozens of students running and walking away from the school, weaving their way between large numbers of emergency vehicles including police cars, ambulances and fire trucks.
Police officers in helmets, bulletproof vests and armed with automatic weapons were seen stationed at several points around the school.
#BSO is working a developing incident regarding a report of active shooter located at 5901 Pine Island Rd, Parkland. Here's what we know so far: deputies are responding to reports of a shooting at Stoneman Douglas High. There are reports of victims. PIO will be on scene 3:15pm.
Terrified students were hiding in closets and under desks as they texted for help.
Police from neighbouring Coral Springs advised teachers and students in the building to "remain barricaded inside until police reach you".
Students are released from a lockdown outside of Stoneman Douglas High School in Parkland after an active shooter opened fire.
Students released from a lockdown are overcome with emotion following following a shooting at Marjory Stoneman Douglas High School in Parkland.
'Everyone started running'
Student Jeiella Dodoo told CBS News she and her schoolmates had evacuated their classroom calmly after hearing what they thought had been a routine fire alarm.
"The alarm went off so we had to evacuate from our classes," she said.
"Then we heard gunshots. I heard about six gunshots.
"And then some people started running and then everyone started running because we were like, 'If it's real, then just run.'"
A math teacher at the school told CBS that he was hiding with six of his students.
"We are fine. We are waiting," he said.
Caesar Figueroa told CNN his daughter was hiding in a closet and texting her family.
"She's trapped with her 10 friends. She said she heard gunshots. A window blew and everybody is screaming and running, and she said she ran in the closet and she's still there," Mr Figueroa said.
No child should 'feel unsafe'
US President Donald Trump tweeted his "prayers and condolences" to the victims.
"My prayers and condolences to the families of the victims of the terrible Florida shooting," President Donald Trump said on Twitter.
"No child, teacher or anyone else should ever feel unsafe in an American school."
Marjory Stoneman Douglas High School, part of the Broward County public school district, has nearly 3,000 students, according to 2014 figures.
The shooting, one of several since the start of the year, will once again throw the spotlight on America's epidemic of gun violence and the ready accessibility of weapons, with 33,000 gun-related deaths annually.
My prayers and condolences to the families of the victims of the terrible Florida shooting. No child, teacher or anyone else should ever feel unsafe in an American school.
Since January 2013, "there have been at least 283 school shootings across the country -- which averages out to one school shooting a week," according to Everytown for Gun Safety, a non-profit group that advocates for gun control.
Since the 2012 massacre at the Sandy Hook Elementary School in Newtown, Connecticut, where 20 children and six adults were shot dead, warning procedures and emergency drills have multiplied at US schools.
The goal is to teach school children how to react to a shooter who opens fire at random.