The gunman shot people in the parking lot before entering the restaurant, where he continued firing until a customer grabbed the rifle, Nashville Police spokesman Don Aaron said. Four people were also wounded before the gunman fled, shedding his jacket.
Authorities said they were searching for the suspect, 29-year-old Travis Reinking, and that they were drafting murder warrants for him. Reinking was arrested last year by the U.S. Secret Service for being in a restricted area near the White House.
Nashville police tweeted that the pickup truck the gunman drove to the restaurant was registered to Reinking.
In a news release, Metropolitan Nashville Police identified those killed Sunday as 29-year-old restaurant worker Taurean C. Sanderlin of Goodlettsville, 20-year-old restaurant patron Joe R. Perez of Nashville, and 23-year-old Akilah Dasilva of Nashville.
The statement says Sanderlin and Perez were killed outside the restaurant and Dasilva was critically wounded inside and later died at Vanderbilt University Medical Center. Deebony Groves, a 21-year-old woman from Gallatin, Tennessee, was fatally wounded inside the restaurant.
Also being treated for gunshot wounds at Vanderbilt are 21-year-old Shanita Waggoner and 24-year-old Sharita Henderson, both of Nashville.
Witness Chuck Cordero told The Tennessean newspaper he had stopped to get a cup of coffee and was outside the restaurant when the chaos unfolded around 3:25 a.m.
"He did not say anything," Cordero said of the gunman, who he described as "all business."
Cordero said the man who wrested the gun from the suspect saved lives. "Had that guy had a chance to reload his weapon, there was plenty more people in that restaurant," he said.
Police identified the man who grabbed the weapon as 29-year-old James Shaw Jr.
NEW: James Shaw Jr., a patron at the Waffle House called a "hero" for wrestling the gun away from the shooter, on the incident: "The gun was kind of jammed up, and it was pushed down, so we were scuffling... and then I grabbed it from him, and I threw it over the countertop." pic.twitter.com/UNqBB5Oh8J— World News Tonight (@ABCWorldNews) April 22, 2018
Shaw told the Tennessean in an interview that he was "just trying to get myself out. I saw the opportunity and pretty much took it."
The newspaper reported that Shaw was grazed by a bullet, treated and released.
"When I was in the ambulance to hospital I kept thinking that I'm going to wake up and it's not going to be real," Shaw said. "It is something out a movie. I'm OK though, but I hate that it happened."
Aaron, the police spokesman, said three people died at the restaurant and one person died at Vanderbilt University Medical Center, where two others were being treated for gunshot wounds. Medical Center spokeswoman Jennifer Wetzel said one was in critical condition and the other was in critical but stable condition.
TriStar Southern Hills Medical Center spokeswoman Katie Radel in Nashville said two people were treated for minor injuries and released.
Aaron said the gunman arrived at the restaurant and waited in the parking lot for four minutes before shooting two people outside.
At some point after the gunman entered, Shaw grabbed his rifle and tossed it over a counter, Aaron said. The gunman then fled and was seen walking, nude, on a road, authorities said.
Police were still searching for him amid a steady rain more than 10 hours after the shooting.
Aaron said Reinking lived near the restaurant in the working- and middle-class Antioch neighborhood of southeast Nashville, and police used yellow crime scene tape to block public access to an apartment complex about a half-mile from the Waffle House.
Reinking is originally from Morton, Illinois, and was known to both Illinois and federal law enforcement, Aaron said.
The victims' names weren't immediately released.
Police initially described Reinking as a person of interest, but Aaron later told reporters authorities were searching for "a gunman we fully believe to be Travis Reinking."
"I think it's safe to say that person of interest and suspect in this matter is synonymous," he said.
"This is a very sad day for the Waffle House family," the company said in a statement on Twitter. "We ask for everyone to keep the victims and their families in their thoughts and prayers."
Nashville Mayor David Briley described the shooting as "a tragic day" for the city.
"My heart goes out to the families & friends of every person who was killed or wounded," Briley said in an emailed statement. "I know all of their lives will be forever changed by this devastating crime."
U.S. Rep. Jim Cooper, whose district includes Nashville, said in an emailed statement that the shooting shows the need for tighter restrictions on "widespread civilian access to military-grade assault weapons."
Tennessee Gov. Bill Haslam said he and his wife, Crissy, "are deeply saddened by the tragic incident in Antioch early this morning, and we mourn the lives taken in this senseless act of violence."
The Waffle House company issued a statement to ABC News:
"We are deeply saddened by this tragic incident. Right now, our first thoughts are with the victims and their families, and we will be there for them in this most difficult time. We are still gathering the details, and so we do not have much information to share. While this is an active investigation, we defer all questions about the incident o the Metro Police in Nashville. Our Senior Vice President, Area Vice President, Division Manager and other members of management are on site now to assist in any way they can. We also have a corporate team on the way from Atlanta. This is a very sad day for the Waffle House family, and we ask everyone to keep the victims and their families in their thoughts and prayers."
NEW: Waffle House issues a statement on the deadly shooting near Nashville: "This is a very sad day for the Waffle House family, and we ask for everyone to keep the victims and their families in their thoughts and prayers." https://t.co/qRl78Wh0sb pic.twitter.com/6QxRXvFcdr— ABC News (@ABC) April 22, 2018
The Associated Press contributed to this report.