The oldest indigo-dyed fabric ever found has been discovered in Peru, pushing back the use of this blue coloring to at least 6,200 years ago.

Previously, the oldest sample of blue-dyed fabric dated to around 4,400 years ago in Egypt, with the oldest written references to blue dye going back to around 5,000 years ago in the Middle East. The discovery in Peru, however, shines a spotlight on the Americas, which are less-discussed in terms of firsts, said study researcher Jeffrey Splitstoser, an archaeologist and textile expert at The George Washington University.

"The people of the Americas were making scientific and technological contributions as early and in this case even earlier than people were in other parts of the world," Splitstoser told Live Science. "We always leave them out. I think this finding just shows that that's a mistake." [Gallery: See Images of the Oldest Indigo]

RELATED: Oldest Known Dress Made More Than 5000 Years Ago

The dyed fabric pieces are small scraps made of woven cotton. They were excavated by archaeologists Tom Dillehay and Duccio Bonavia between 2007 and 2008 from a prehistoric site called Huaca Prieta, which is north of the city of Trujillo in coastal Peru. Huaca Prieta was a prehistoric dwelling that was covered by a mound and turned into a temple, Splitstoser said. The temple was made of a sort of concrete mixed from ash, shells and sand; over the years, many layers of this material had been applied to the structure as local people renovated and rebuilt the temple. The fabric scraps were found in bundles lining the ramp that led up to the top of the temple, embedded in the concrete-like layers. They all date to between 4,000 and 6,200 years ago.

"They were literally sealed under these new layers of building, but because the building material had so much ash in it, it leached into the textiles, making them a very dirty, sooty color," Splitstoser said.

RELATED: Ancient Burial Shroud Made of Surprising Material

The blue color didn't appear until conservationists washed the textiles. Almost all blue dye in nature comes from the compound indigoid, Splitstoser said, which can be made by many plants. But the first tests on the fabric yielded no sign of indigoid. Splitstoser was stumped.

He persevered, finding another chemist -- Jan Wouters of University College London -- with more sensitive equipment. Wouters, using a sensitive technique called high-performance liquid chromatography, was able to tease out the chemical makeup of the dye to discover that it was, in fact, indigo. He tested eight tiny samples of the blue cotton and confirmed indigo in five of them.

"That's when we realized then that we had the world's oldest indigo, by far," Splitstoser said.

RELATED: Oldest Known Pair of Pants Unearthed

The fabric pieces were all cut or torn before they were deposited on the temple ramp, which probably represented a ritual "killing," by peoples who viewed objects as living, Splitstoser said.

"We see that all over the Andes. They not only ritually killed textiles, but they ritually killed ceramics. Anything that was buried was broken," he said. [Photos: Journey Into the Tropial Andes]

Some of the fabrics showed signs of being wetted and then squeezed out, possibly as part of the ritual, Splitstoser said. The fabrics weren't just blue - they were woven in patterns made of blue-dyed yarn, natural off-white cotton and bright-white thread made from milkweed, a very rare textile in South America, Splitstoser said. The yarn had also been dipped in red and yellow ochre, an iron pigment often used in rock art. Unlike the indigo, the ochre would have run when wetted.

"If you were to pour water on those and then squeeze it, you'd get colored water pouring out of the textiles, which might have been part of the show," Splitstoser said. No one knows what these rituals might have represented to the people who invented them; the era in which the textiles were made was one of a drying climate, Splitstoser said, so perhaps the rituals had to do with rain or water.

WATCH VIDEO: Why Do Clothes Shrink When You Wash Them?