A sheriff's investigator at the scene said the wounded deputy, a 26-year veteran of the agency, was expected to recover.
The suspect was apprehended by a K-9 unit after a manhunt of nearly two hours.
The attack occurred shortly before 10 a.m. at a Jack in the Box near the intersection of Crossglade Avenue and Soledad Canyon Road.
The plainclothes detective, assigned to the sheriff's Special Victims Bureau, was walking out of the restaurant when he "was confronted by a suspect who asked him if he was a deputy," LASD Capt. Darren Harris said at a news conference.
"When he told him he was a deputy," the assailant immediately stabbed him once in the upper torso and then fled into the neighborhood, the captain said.
The wounded detective managed to make a radio call for help from his vehicle, Harris said.
A flood of emergency responders descended on the location, and law-enforcement vehicles then escorted an ambulance to nearby Henry Mayo Newhall Hospital.
The incident triggered a massive search in the area, where authorities set up a perimeter and were assisted by a sheriff's helicopter overhead.
Three armored SWAT vehicles and more than a dozen deputies were seen outside of a home in the neighborhood. A man was detained after he exited the residence with his hands in the air, but it was unclear if he was connected to the stabbing.
#LASD SEB and @SCVSHERIFF personnel worked together to locate and arrest the assault w/deadly weapon on a Deputy suspect in the area of Nearbrook St. and Altamere Ave, Canyon Country. Neighborhood is safe. pic.twitter.com/sUkpH9prvY— SEB (@SEBLASD) January 8, 2018
A standoff at that scene ended when a K-9 unit located another man, the suspected assailant, hiding in a backyard. He was later identified by authorities as 21-year-old Donald Chinchilla.
"It's unreal. It's surreal. Someone stabbing a cop at Jack-in-the-Box? You don't hear that quite often," Christian Chinchilla told ABC7 before the suspect was identified.
What he didn't know at the time was that the man believed to have stabbed the deputy was a member of his own family. Another family member was detained at the time of Donald Chinchilla's arrest.
According to sheriff's officials, Chinchilla was transported to a hospital for treatment after being bitten by the K-9.
Family members claim Donald Chinchilla was a non-violent person and said they have no idea why he would be involved in the crime.