Police said Cruz was armed with multiple magazines and at least one AR-15 style rifle.
A girl who had evacuated for the fire alarm said there were several hundred students who never heard the gunshots.
"Our hearts are with the students, families, staff and the entire Marjory Stoneman Douglas High School community as we deal with this tragedy", the Broward County School District said in a tweet Wednesday night.
Mark Klein was waiting to pick up his son Manny, a ninth-grader who was able to call him during the lockdown at the school to say he was OK.More news: Why Peter Thiel Is Leaving Silicon Valley for LA
While inside the building, a student shared a photo as they took cover during the shooting.
Sanders said, "We continue to keep the victims, and their friends and family, in our thoughts and prayers".
The shooting was the nation's deadliest school shooting since a gunman attacked Sandy Hook Elementary School in Newtown, Connecticut, more than five years ago.
A group of police officers stand guard in front of the side entrance of the Marjory Stoneman Douglas High School.
As news of the shooting spread, desperate parents gathered near the property searching for their children.More news: Featured Stock to Focus: BP plc (NYSE:BP)
US Senator Bill Nelson of Florida told CNN the gunman wore a gas mask, was carrying smoke grenades and set off a fire alarm, prompting a mass evacuation.
"All of a sudden there was a really loud noise....people are crying the closet", the student wrote to CBS Miami's Rick Folbaum via text message. A student told WFOR-TV that other students "knew it was going to be him". Long live Majory Stoneman Douglas High.
Parkland is about 24km west of Fort Lauderdale in the USA state of Florida.
It was the 18th shooting in a United States school so far this year, gun control group Everytown for Gun Safety said.
Police are now looking for answers as they piece together what happened and determine the motives that led a gunman to open fire at Parkland high school killing 17 people.More news: Venezuela's Maduro orders reopening of Miami consulate before election
It was the 18th shooting in a USA school so far this year, according to gun control group Everytown for Gun Safety.