LOUISVILLE, Ky. – They flew for years – their stars and stripes soaked, sun-baked and frozen countless times outside homes on tree-lined streets, high above car dealerships and at government offices.

The roughly 25,000 tattered and faded U.S. flags – turned in to the American Legion by owners unsure of how to properly dispose of them – lay packed on wooden pallets, soaked in diesel fuel and covered by a mammoth 50-foot flag on a rural Louisville farm.

As the sun set Saturday, dozens of veterans whose service spread from World War II to Iraq watched silently as the edges of the funeral-like pyre of flags were lit.

Rifles from an honor guard cracked 21 times. Taps played as flames sent plumes of black smoke into the darkening sky.

Burning an American flag has been used by some as the ultimate form of protest, an act that many see as sacrilegious. But under U.S. federal code, burning is the preferred way to properly "retire" a flag.

American Legion “G.I. Joe” Post 244 in Jeffersontown, Kentucky, has become known for its large ceremonies that have torched as many as 40,000 flags at once.

"A lot of people go, 'Why do you burn the flags?' " said post member Steve Martin. "It’s not disrespect."

Congress set the rules for burning flags

Though ceremonial protocol for retiring flags was created in 1923, it wasn't until 1942 that Congress adopted the code, said Peter Ansoff, president of the North American Vexillological Association, which studies flags.

Along with a litany of rules about flags, including that they not touch the ground or be used as bedding, the code states that a flag whose condition is “no longer a fitting emblem for display, should be destroyed in a dignified way, preferably by burning.”

Flag etiquette:Flag Day is June 14: Here's what you need to know about flag etiquette

About 150 million American flags are sold every year, according to the Flag Manufacturers Association of America. Many are donated to veterans groups such as the American Legion or to other groups such as the Boy Scouts for disposal.

Flags can also be cut up, buried or sent to a flag recycler.

"Really, what you're doing is holding a funeral for the flag," said Jeff Hendricks, a deputy director at the American Legion's National Headquarters in Indianapolis.

Though some U.S. cities have banned the burning of flags made with materials such as nylon, Kentucky's Energy and Environment Cabinet website says ceremonial fires are allowed.

A story in every star and stripe

The Jeffersontown post’s flag burning ceremonies are held on the Shelby County farm of member Hugh Colbert, whose father served in Myanmar, formerly known as Burma, during World War II.

Among the veterans and families in attendance Saturday was a 93-year-old World War II landing craft engineer who called the invasion of Guam “no picnic.” Nearby was a retired Air Force officer who helped command America’s nuclear missile arsenal.

There was a jet mechanic who served Vietnam-era planes, a retired soldier who was among the last U.S. units to leave Iraq in 2011 and the wife of an Army officer who just returned from a deployment in Kuwait.

Pell Blakeman, 65, marveled at the unknown histories of the flags that arrived in bags and pallets on a flatbed trailer.

Most were dropped anonymously. Some were tiny and others large; all were packed tightly and pressed together.

"I’m certain there are great stories in that pile," he said.

A chance to remember those who came before

By 8:30 p.m., a flag flying on a pole was lowered and folded, presented by an honor guard to the post commanders in a scripted ritual that plays out each year. It's one of reverence and deep meaning for those who attend.

“These flags have become faded and worn over the graves of our departed comrades and the soldier, Marine, sailor and airman dead of all our nation’s wars,” said Kurt Hall, the post commander, calling them “a precious symbol of all that we and our comrades have worked for and lived for.”

After a prayer from Chaplain Barry Harkness, an Air Force veteran and Baptist pastor, Colbert’s son lit the flags. Aging vets stood quietly alongside younger couples holding babies.

Several veterans said they got chills watching.

“I think about the things my father, my uncles … all my brothers and sisters gave up,” said Jim Walser, from a family with generations of military service. “It’s very emotional.”

Darkness fell, and the fire kept burning. Most packed up and left. They knew there might already be more flags dropped off at the post's mailbox.

By morning, all that remained were ashes and metal grommets.

Follow Chris Kenning on Twitter: @chris_kenning