The idiom 'line drawn in the sand' by today's usage would mean the limit of what's acceptable. According to William Safire's collection of magazine stories published in his book In Love With Norma Loquendi (Random House, 1994), there are two possible sources for the phrase.

It may have its origins in Roman history. Aspiring to restore the Grecian Empire as in the days of Alexander the Great in 163 BC Antiochus IV invaded Egypt. Antiochus IV came to the Seleucid throne in Syria as a tyrannical ruler, he was harsh, savage, and cruel. 'Wearing his pride like a garment' he sincerely believed he was a god. Convinced that he was deity in the flesh he began to call himself Antiochus Theos Epiphanes. Antiochus, meaning the visible god, or shortened to Antiochus Epiphanes, his deriders soon named him Epiphanes or madman. Antiochus decided to invade Egypt where he encountered an envoy dispatched by the Roman Senate by the name of C. Popillius Laenas. Meeting up at Eleusis, four miles out side of Alexandria, Popillius insisted that Antiochus withdraw. Stalling for time, Popillius insisted that Antiochus make a decision. Drawing a circle in the sand around Antiochus with his walking stick Popillius demanded he make up his mind before stepping out of the circle. Unwilling to invoke the ire of the Roman Empire, Antiochus reluctantly agreed to retreat to everyones astonishment. Thus a new kind of diplomacy was born and Roman history has never forgotten it. Returning to Syria in humiliation Antiochus invaded Jerusalem breaching the city walls where homes were burned to the ground and tens of thousands of Jewish people were killed or sold into slavery. A madman indeed.

The second origin is a little more suspect but has made its way into American history as a legend about crossing a line in the sand. It begins in the nineteenth century as one of a great variety of tall tales out of Texas that they're so famous for. It begins with:

The Battle of the Alamo

    In late February of 1836, General Antonio de Santa Anna arrived in San Antonio with about 5,000 Mexican soldiers. The Texans at this point in time had only 150 volunteers behind the walls of the Alamo. On February 24, the Texans received 32 men from Gonzales, bringing their total to 182 men. The men were led by both Jim Bowie and William Travis, but later Travis took over full command when Bowie became ill. Another of the heroes behind the walls of the Alamo included Davy Crockett from Tennessee.

    Twice the Mexican army charged, but each time they were driven back and had to retreat. On March 5, Travis ordered everyone to the center of the mission. Then he said he was willing to die but he wouldn't force any man to do so. Then he drew a line in the sand and asked everyone who was willing to die to cross the line. Only one man didn't cross the line. He then was asked to gather his things and leave.

The origins of the line in the sand story arise from a letter written at that time by W.P. Zuber, the son of a Texas pioneer and was subsequently published in the 1873 Texas Almanac. According to the Zuber, William B. Travis had assembled troops at the Alamo knowing that most likely this would be a fight to the death,hence he gave the men a choice of fighting or leaving. Drawing a long line in the dust from one end of the troop formation to the other he invited them to step across it to show him that they would fight with him to the end. Jim Bowie, too sick to walk and confined to a litter asked others to carry him across the line. Supposedly there was one man by the name of Moses Rose who refused to cross the line and fled over the walls of the Alamo. The story was so embellished by Zuber that it lost a lot of credibility. However there is some evidence to its veracity, there was indeed a butcher in Nacogdoches,TX during the years after the war who gave testimony for claims by descendents of men who died at the Alamo. In 1853 his decedents claimed property offered to all survivors of the Alamo because Rose was regarded as a traitor the claim was denied. More proof of the tale come from Mrs. Dickenson another survivor of the Alamo. She gave testimony that William Travis gave everyone the choice to fight or leave and that a man named "Ross" took up the offer to leave. This may be the line in the sand incident and the name "Ross" being similar to "Rose" lends some belief to the story. The legend itself has been the subject of many heated debates in the Lone Star State and the decision of the garrison to face the Mexicans in a fight for their freedom during the "13 days of glory" and is one reason why that line crosses into the hearts of Texans when they "remember the Alamo."

Sources:

The Battle of the Alamo:
www.karnes-city.isd.tenet.edu/cfair/alamo.html

In Search of Heroes:
http://www.graceproducts.com/travis/line.html

Word Dectective:
http://www.word-detective.com/backidx.html