Late in 1876, so the story goes, a young man named John Warne Gates built a wire-fence pen in the middle of San Antonio, Texas.

He rounded up some of the toughest and wildest longhorns in all of Texas. That's how he described them.

Others say the cattle were a docile bunch. And there are those who wonder whether this particular story is true at all. But never mind.

John Warne Gates - who would become known as "Bet A Million Gates" - took bets from onlookers as to whether the powerful beasts could break through the fragile-seeming wire. They couldn't.

Image copyright Alamy Image caption John Warne Gates was quick to see the potential of barbed wire in redefining the US landscape

Even when Gates's sidekick, a Mexican cowboy, charged at the cattle howling Spanish curses and waving a burning brand in each hand, the wire held.

Bet-A-Million Gates was selling a new kind of fence, and the orders soon came rolling in.

Transformative

The advertisements of the time touted it as "The Greatest Discovery Of The Age", patented by Joseph Glidden, of De Kalb Illinois. Gates described it more poetically: "lighter than air, stronger than whiskey, cheaper than dust".

We simply call it barbed wire.

50 Things That Made the Modern Economy highlights the inventions, ideas and innovations that helped create the economic world.

It is broadcast on the BBC World Service. You can find more information about the programme's sources and listen online or subscribe to the programme podcast.

Calling it the greatest discovery of the age might seem hyperbolic, even allowing for the fact that the advertisers didn't know Alexander Graham Bell was about to be awarded a patent for the telephone.

But while we accept the telephone as transformative, barbed wire wrought huge changes on the American West, and much more quickly.

Joseph Glidden's design for barbed wire wasn't the first, but it was the best.

Image copyright Alamy Image caption Joseph Glidden's barbed wire would make his fortune

Glidden's design is recognisably modern.

The wicked barb is twisted around a strand of smooth wire, then a second strand of smooth wire is twisted together with the first to stop the barbs from sliding around. American farmers snapped it up.

There was a reason they were so hungry for it.

A few years earlier, President Abraham Lincoln had signed the Homestead Act of 1862.

Uncharted territory

The act specified that any honest citizen - including women, and freed slaves - could lay claim to up to 160 acres (0.6 sq km) of land in America's western territories. All they had to do was build a home there and work the land for five years.

Image copyright Chris Dorney / Alamy Stock Photo Image caption The 1862 Homestead Act set out the rules on who could own land in the western territories

It sounds simple.

But the prairie was a vast and uncharted expanse of tall, tough grasses, a land suitable for nomads, not settlers. It had long been the territory of the Native Americans.

After Europeans arrived and pushed west, the cowboys roamed free, herding cattle over the boundless plains.

But settlers needed fences, not least to keep those free-roaming cattle from trampling their crops. And there wasn't a lot of wood - certainly none to spare for fencing in mile after mile of what was often called "The American Desert".

Farmers tried growing thorn-bush hedges, but they were slow-growing and inflexible. Smooth wire fences didn't work either - the cattle simply pushed through them.

Barbed wire changed what the Homestead Act could not.

Image copyright Alamy Image caption By the end of the Civil War, in 1865, 15,000 homestead claims had been established

Until it was developed, the prairie was an unbounded space, more like an ocean than a stretch of arable land.

Private ownership of land wasn't common because it wasn't feasible.

'The devil's rope'

Barbed wire also sparked ferocious disagreements.

The homesteading farmers were trying to stake out their property - property that had once been the territory of various Native American tribes. No wonder those tribes called barbed wire "the devil's rope".

The old-time cowboys also lived on the principle that cattle could graze freely across the plains - this was the law of the open range. The cowboys hated the wire: cattle would get nasty wounds and infections.

When the blizzards came, the cattle would try to head south. Sometimes they got stuck against the wire and died in their thousands.

Other cowmen adopted barbed wire, using it to fence off private ranches. And while barbed wire could enforce legal boundaries, many fences were illegal - attempts to commandeer common land for private purposes.

As the wire's dominion spread, fights started to break out.

Image copyright Alamy Image caption The settlers' barbed wire fences inflamed tensions with Native Americans

In the "fence-cutting wars", masked gangs such as the Blue Devils and the Javelinas cut the wires and left dire threats warning fence-owners not to rebuild. There were shootouts and some deaths.

Eventually, the authorities clamped down. The fence-cutting wars ended, The barbed wire remained.

"It makes me sick," said one trail driver in 1883, "when I think of onions and Irish potatoes growing where mustang ponies should be exercising and where four-year-old steers should be getting ripe for market."

And if the cowboys were outraged, the Native Americans suffered much more.

These ferocious arguments on the frontier were reflected in a philosophical debate.

The English 17th Century philosopher John Locke - a great influence on the founding fathers of the United States - puzzled over the problem of how anybody might legally come to own land. Once upon a time, nobody owned anything.

Image copyright Hulton Archive Image caption Philosopher John Locke had a great influence on the founding fathers of the United States

Locke argued that we all own our own labour. And if you mix your labour with the land that nature provides - for example, by ploughing the soil - then you've blended something you definitely own with something that nobody owns. By working the land, you've come to own it.

Nonsense, said Jean-Jacques Rousseau, an 18th Century philosopher from Geneva who protested against the evils of enclosure.

In his Discourse on Inequality, he lamented "the first man who, having enclosed a piece of ground, bethought himself of saying, 'This is mine,' and found people simple enough to believe him." This man, said Rousseau, "was the real founder of civil society".

The importance of ownership

He did not intend that as a compliment.

But it's certainly true that modern economies are built on the legal fact that most things - including land and property - have an owner, usually a person or a corporation.

The ability to own private property also gives people an incentive to invest in and improve what they own - whether that's a patch of land in the American Midwest, or an apartment in the Indian city of Kolkata (Calcutta), or even a piece of intellectual property such as the rights to Mickey Mouse.

More from Tim Harford

The warrior monks who invented banking

How the invention of paper changed the world

Why the falling cost of light matters

The great intellectual property trade-off

It's a powerful argument - and it was ruthlessly and cynically deployed by those who wanted to argue that Native Americans didn't really have a right to their own territory, because they weren't actively developing it in the style that Europeans saw fit.

So the story of how barbed wire changed the West is also the story of how property rights changed the world.

And it's also the story of how, even in a sophisticated economy, what the law says sometimes matters less than matters of simple practicality.

The 1862 Homestead Act laid out the rules on who owned what in the western territories. But those rules didn't mean much before they were reinforced by barbed wire.

Meanwhile, the barbed wire barons Gates and Glidden became rich - as did many others.

The year that Glidden secured his barbed wire patent, 32 miles (51km) of wire were produced.

Six years later, in 1880, the factory in De Kalb turned out 263,000 miles (423,000km) of wire, enough to circle the world 10 times over.

Tim Harford writes the Financial Times' Undercover Economist column. 50 Things That Made the Modern Economy is broadcast on the BBC World Service. You can find more information about the programme's sources and listen online or subscribe to the programme podcast.