A man identified as Jestin Anthony Joseph, 24, allegedly entered the McDonald's shortly after 9 p.m. Tuesday and was distracted by an employee and confronted by a customer, allowing others to escape, the Fort Worth Star-Telegram reported.
The customer fought briefly with the gunman, the report said.
The gun malfunctioned and did not fire until the suspect went outside and fired twice at a passing car, police said.
Joseph fled, was arrested shortly afterward and was being held on outstanding warrants and suspicion of aggravated robbery, with bail set at $500,000, police said.
At least 15 people, including children, were inside the restaurant at the time of the incident. Police described the employee and customer as heroes.
"My gut feeling here is that the city of Fort Worth and the Fort Worth Police Department avoided a major tragedy Tuesday night," Sgt. Joe Loughman said.
A few hours before the robbery, the suspect's mother told police that she feared her son was suicidal.
He had previously been arrested for narcotics violations and assault, police said.