Your ancestors were once scared to death of a condiment. No, really, they were.

They were so afraid, in fact, we came within a whisker of losing our most beloved sauce. This was what happened when America was terrified of ketchup.

If you think that sweet gooey treat was born in the 1950s when Richie, Potsie and Fonzie slathered it on french fries at Arnold’s Drive-in on “Happy Days,” think again. Ketchup, (or catsup for the linguist purists among us), goes way back beyond that.

It’s been around for ages, first popping up in America in 1682, though in colonial times it was made from mushrooms. Tomatoes gradually took over in the 19th century. An 1817 cookbook recipe included anchovies. By the 1850s, anchovies were out and sweetening it with sugar was in, and the product we know today began to emerge.

Civil War soldiers wrote home begging for it to break up the monotony of military food.

Ketchup in its different variations has been sold for centuries. Farmers who made it from their crops peddled it. Jonas Yerkes is believed to be the first American to bottle and sell the stuff.

H.&J. Heinz jumped into the market in a big way, unveiling its signature Heinz Tomato Ketchup in 1876, promoting it with the snappy slogan, “Blessed relief for Mother and other women in the household!”

By the 20th century, ketchup was mainstream. There were more brands than you could shake the proverbial stick at. But all faced the same serious problem. Ketchup had a limited shelf life.

The stuff rotted over time. Unscrupulous manufacturers hid it inside bottles made of brown, green or blue glass. Customers didn’t know if their container held a contaminated condiment until they took it home and opened it.

Henry Heinz solved that problem by putting his ketchup in clear glass bottles. Though it cost a penny more than the cheaper colored glass, he figured consumers would pay extra to know exactly what they were getting. His gamble paid off, eventually forcing the entire industry to switch to clear glass.

But that solved only part of the problem. The bottling process involved fermenting tomatoes. As the 19th century drew to a close, fermentation increasingly produced explosions.

Yes, you read correctly. Bottles of the good ol’ American ketchup mom kept in her pantry were blowing up!

Consider this 1895 New York Sun article: “A bottle of catsup exploded on the dinner table of a family at Michigan City, Indiana, recently, and force-knocked all the dishes off the table.”

Or how about this Saint Paul Globe headline from 1903: “Bottle of Catsup Explodes in Her Hands: 12-Year-Old Girl Badly Cut By Flying Glass.”

Ketchup was no longer delicious; it was potentially deadly.

Another factor was also to blame. Manufacturers were increasingly spiking the product with chemicals. Turn-of-the-century studies showed many even contained some form of antiseptic.

Dr. Harvey Wiley, head of the U.S. Department of Agriculture’s chemistry division, enlisted young male workers to eat various preservatives and studied the results. Dubbed The “Poison Squad” by the press, they cataloged enough physical side effects (everything from headaches and heartburn to cramping and constipation) to fill a hospital.

The culprit was finally identified. Benzoates, the era’s preservatives of choice, were making consumers sick as bottles were blowing up.

Hard as it is to imagine today, some folks wondered if ketchup sales should be banned altogether.

Once more, it was Henry Heinz to the rescue. A backer of transparency in the food industry, in 1906 his researchers found a way to make the sauce Americans craved without benzoates. The secret was going wild with twice as much salt, sugar and vinegar as before. Over the next two years, Heinz churned out 12 million bottles without one spoiling.

Heinz again gambled customers would be willing to pay more for a better product, and yet again he hit the jackpot.

The benzoate lobby (and there was such a thing) hit back hard. A nasty war was waged on the pages of academic journals. A blue-ribbon panel decreed benzoate safe if eaten in small amounts.

But Americans weren’t buying it, either intellectually or fiscally. They voted with their pocketbooks. By 1911, Heinz and his preservative-free ketchup had won the day.

The fracas even played a role in the Food and Drug Administration’s creation in 1906.

So, the next time you lift the bun off a burger or hoist a bottle over a hotdog, stop and remember Heinz, Dr. Wiley, the Poison Squad, and all others who made ketchup safe for democracy. You’d be eating mustard without them.