An E. coli epidemic traced to fast food had left behind a restaurant chain at which people were terrified to eat.

At lunchtime, once-popular restaurants resembled ghost towns. Stories of children suffering seizures and strokes after family outings spread as incidents multiplied. Within months of the first reports of infections, people wondered if customers would ever return, and a shareholder meeting opened with a prayer for the sick.

“It’s your worst, worst nightmare,” the company’s CEO told the Seattle Times.

The episode at Jack in the Box JACK, -2.18% , which started in late 1992, ended with four deaths, 144 hospitalizations, and more than 500 lab-confirmed infections, according to the Centers for Disease Control and Prevention. The company’s reputation was badly battered, and it bled billions in legal and medical expenses, as well as lost business, in the years that followed.

It’s now mostly ancient history for Jack in the Box, which has restored its brand, sales, share price and place among the nation’s leading chains. But the story is recalled in the recent trials of Chipotle Mexican Grill CMG, -0.80% , which sickened 55 in an E. coli outbreak that ran from October to December.

The inside of an empty Chipotle Mexican Grill in New York City, seen through the window, at lunchtime on Feb. 8, 2016. The chain closed stores for lunch nationwide for a meeting on food safety following a number of E. coli outbreaks. Reuters

Few of Chipotle’s customers likely recall Jack in the Box’s “nightmare. ” Many weren’t even alive at the time. But the way the burger chain eventually rebuilt itself — by focusing on its product, culture and messaging — offers a view of Chipotle’s way forward.

‘These are incredibly ill kids’

Jack in the Box’s story began in November 1992, as cases of E. coli — the source of which was initially unknown — emerged in the Pacific Northwest. About 50 people, mostly children, had been affected by the time officials linked the illness to the restaurant chain the next January.

The cases skewed young as more cases were identified: A January 1993 Seattle Times story said that of 150 cases, two-thirds were 15 years old and younger. Health officials have said the particular strain of the bacteria, E. coli 0157: H7, is especially dangerous to the very young.

“These are incredibly ill kids,” Dr. Ellis Avner, then the director of nephrology at Children’s Hospital in Seattle, told the Times in January 1993.

Three-year-old Mary Dolan, one of the earlier cases, grew feverish and then had cramps and bloody diarrhea after eating a Jack in the Box cheeseburger. After she was hospitalized, she had a seizure and a stroke.

Mary improved, but others were less fortunate. The first to die, Tacoma, Wash., two-year-old Michael Nole, succumbed to kidney and heart failure in late January after eating an infected cheeseburger. His parents eventually settled with the company for more than $1 million.

By the end of January 1993, more than 300 reports of E. coli were connected to Jack in the Box; the count eclipsed 450 by the end of February. Mild cases of E. coli 0157: H7 can pass in a week, but many saw worst-case scenarios play out, experiencing excessive bleeding and central nervous system damage. At least 29 had kidney failure.

Jack in the Box, then the fifth-largest American burger chain, had about 1,200 restaurants, all in the western U.S. The ourbreak covered the same ground. As the numbers grew, so did the certainty that Jack in the Box was the culprit: “Virtually all” of the infected burgers were linked to the company, according to health officials.

Sales and profits quickly dropped. Shares of Jack in the Box, then trading as parent company Foodmaker Inc., fell from highs around $14 before the outbreak to below $10 by January 22. Plans for new restaurants were shelved.

In one two-week period in January, sales were 35% below the previous year’s levels. The effects lingered, with full-year 1995 sales nearly 20% below 1993 revenues.

The company did not respond to a request for an interview about its 1990s troubles and their parallels with Chipotle today.

Today, though, Jack is still standing — and then some. It remains the fifth-largest U.S. burger chain, and has about 1,000 more restaurants than in 1993. Its shares have substantially outperformed the S&P 500 this decade.

Perhaps most telling, it shed the Foodmaker name in 1999, and is now known simply by its once-beleaguered brand name, Jack in the Box.

How a company rebuilt its food culture

Even after it became clear that Jack in the Box had served tainted hamburgers, the company and its suppliers dodged responsibility, blaming each other.

The general source of the illnesses was known early on — E. coli 0157: H7, is associated with cows — but investigators didn’t know if it originated with the beef itself or the way it was cooked and handled. Soon after investigators determined that Jack in the Box was the source of the illness, the company blamed its meat supplier, which denied responsibility.

It turned out that both played a role: Jack in the Box wasn’t cooking its burgers to high enough temperatures, though the meat had been so contaminated that it might not have mattered.

The distinction didn’t matter to customers; the food was making people sick. Customer confidence and sales were down, and those who did brave the chain avoided hamburgers.

Once Jack in the Box was implicated in the spread of the illness, it discarded and replaced all of the hamburger meat from its Washington stores and extended cooking time for hamburgers. Two days later, it hired David Theno as a consultant, later bringing him on full-time to guide a two-year food safety plan.

Theno, who is now working with Chipotle, declined to answer questions about his work with that company, though he agreed to share viewpoints about bringing a restaurant chain back from the brink. (Chipotle did not respond to several requests for an interview about its work with Theno and how its issues compare with Jack in the Box’s.)

Evidence would later show that the E. coli had been introduced in the slaughterhouse, although the fast food chain was also undercooking its burgers relative to state guidelines that had been adopted earlier in 1992.

Jack in the Box quickly replaced its meat processor, The Vons Cos., later suing it — and its eight beef suppliers — charging negligence. Jack in the Box got roughly $60 million from them in a 1998 settlement. (Vons, now owned by privately owned Albertsons, is no longer in the meat processing business.)

The company then looked to rebuild its roster of suppliers, applying additional scrutiny to all of its ingredients — not just beef, according to Theno. It developed a system that used spot microbiological testing of randomly selected items to profile and select reliable suppliers.

In the restaurants themselves, cooking temperatures were changed, cooks began handling patties with gloves, and new tools for calibrating grill temperature were adopted. The chain implemented Hazard Analysis and Critical Control Point, a set of food safety management standards developed decades earlier, and trained managers in ServSafe, an industry program geared toward preventing foodborne illness.

Many of these innovations existed at the time, but Jack in the Box was the first to use them all, according to Theno. “People had bits and pieces, but nobody had the full thing,” he said. Today, they’re standard at most restaurants.

Jack in the Box had to change its culture along with its processes, according to Theno, who ended up working there for 15 years and is now CEO of consulting business Gray Dog Partners. “Food safety had to be the default position,” he said.

While food safety controls had been a part of the company’s culture, they weren’t as integral as those for sales or labor costs, according to Theno. HAACP gave Jack in the Box a way to measure food safety and give restaurant workers a stake in the outcome, illustrating what they needed to do, why it mattered and how important it was to customer safety.

Theno even invited representatives from other fast food companies to visit and observe, which he believes helped spread many modern food safety techniques into the mainstream.

“People want to do the right thing when they know what the right thing is,” said Theno. “None of the people at Jack in the Box ever thought anything like that would happen, but once it did, they wanted to make sure nothing like that ever did again.”

Meanwhile, Jack in the Box worked to rebuild its brand. The company apologized early and often, detailing the internal changes it was making in its advertising. After the first E. coli death, it ran ads in Western Washington newspapers with a toll-free number customers could call for more information about their cleanup efforts. Nugent apologized in a commercial aired on network television. And in February 1993, Jack in the Box offered to pay affected customers’ medical costs.

“This is a horrible event,” Jack in the Box Chairman Jack Goodall wrote in a full-page January 1993 advertisement in the Seattle Times and Seattle Post-Intelligencer. “All of us at Jack in the Box extend our prayers for a complete and speedy recovery to everyone who has experienced this illness.”

Chipotle’s response shares similarities with Jack in the Box’s

No new cases of Chipotle-linked E. coli have occurred since December, according to the CDC, which said in February that the outbreak appeared to be over. The government agency couldn’t identify the contamination’s source.

But just after reports of the E. coli episode were emerging, so did those of a norovirus outbreak affecting more than 100 people in a Chipotle restaurant in Boston. That, in turn, brought attention to an earlier norovirus outbreak in a California Chipotle in August. (Reports of more Boston-area norovirus diagnoses spread in early March.)

Together with salmonella outbreaks in Minnesota and Wisconsin in late 2015, they suggested deep-seated food safety problems at the chain, according to food experts.

With hundreds affected and several dead, Jack in the Box’s E. coli episode went far further than Chipotle’s, which affected only 55 people, none of whom died. Still, E. Coli took a big bite out of Chipotle’s bottom line: the company reported fourth-quarter revenue that represented its first-ever year-over-year decline and a 44% drop in net profit.

Its stock price, meanwhile, plummeted after the first reports of E. coli in October. After hovering around a mid-October high of about $750, shares hit a $404.26 low on Jan. 12 before rebounding to about $530 in early March.

The company was the subject of jokes on late-night TV and social media for months. “They know it’s bad and they want it even more,” said TV host John Oliver of customers returning to the chain. “Chipotle is now officially America’s emotionally abusive boyfriend.”

Chairman and co-CEO Steve Ells has called the outbreak “the most challenging period in Chipotle’s history.”

Much of Chipotle’s response, which accelerated after the outbreak was officially declared over in early February, resembles Jack in the Box’s decades earlier — though with more modern technology and infrastructure. Substantial food safety advances in food testing, research and tracking have been developed since 1993.

The company’s “farm-to-fork” model looks a little different these days, with suppliers required to test ingredients before shipping to the company. Those ingredients are then tracked as they move to stores thanks to a tracing system the company says will make potential issues easier to stop and diagnose.

Read more: What Chipotle’s farm-to-fork approach looks like post-food safety scandals

Old-school kitchen tactics — including centralizing some produce preparation, blanching other kinds of produce, marinating salsa and guacamole ingredients in citrus and changing meat marinade procedures — have also helped, according to company officials.

A sign in the window of a Chipotle restaurant in lower Manhattan told customers the restaurant was closed until 3 p.m. on Feb. 8, 2016. Getty Images

To address cultural changes, employees have been retrained and restaurant auditing processes have been updated. Employee incentives have been formed around the new audits, the company has said.

A new marketing campaign, launched in early February and scheduled to run through mid-May, will focus on the company’s “commitment to high-quality ingredients and great tasting food” rather than past food safety issues, said chief creative and development officer Mark Crumpacker.

Chipotle also borrowed a leaf from Jack’s playbook, taking to TV screens and the pages of more than 60 U.S. newspapers for an ad that doubled as an apology.

“The fact that anyone has become ill eating at Chipotle is completely unacceptable to me and I am deeply sorry,” read Ells’ apology. Though eliminating all food risk might not be possible, he wrote, “we are confident that we can achieve near zero risk.”

The company’s marketing efforts, which began Feb. 8, included a free burrito offer and the announcement of a multimillion-dollar fund to help local farmers meet its new food safety standards. And while the Internet has intensified public relations problems for Chipotle — something Jack in the Box didn’t have to worry about — it has also used it to publish information about the outbreak and the steps that have been taken since.

Some are already predicting Chipotle’s full recovery. Sales growth could return in 12 to 15 months post-outbreak, Wells Fargo analysts wrote in a February note that said restaurants in similar situations have historically bounced back.

Deutsche Bank, however, downgraded Chipotle in February, acknowledging the company’s changes but wondering “how well they will be received” and worrying that customer losses could be permanent. And in a Monday note, Credit Suisse wondered whether signs of rebounding sales are skewed by “aggressive promotional efforts... at the expense of ‘real sales.’”

Chipotle’s good-for-you-and-good-for-the-planet branding, meanwhile, could be a strength or a drawback as the company seeks to recover.

“The company has been telling consumers ‘We have better food,’ implying that it’s safer and better for you, it’s all locally grown, ‘We’ve removed the preservatives, artificial ingredients and so on,’” said University of Georgia professor Michael Doyle, who has studied E. coli and developed tests for the disease for decades. “Many of those people who believed in that felt betrayed.”

Business at Chipotle restaurants has picked up in the weeks since the end of the outbreak was announced, though the longer-term question — whether early signs of optimism will once again mean long lines at lunchtime — remains.

If Jack in the Box is any indication, it’s possible. About three years after the start of the burger chain’s outbreak, a November 1995 Seattle Times headline announced the return of happy days for the company: “Jack,” the headline read, “is Back.”

This story was first published on March 8, 2016. It was republished to add a reference to the early March norovirus reports in the Boston area.