I asked a similar question a while ago and got an incredibly thorough and awesome answer here: http://www.reddit.com/r/AskHistorians/comments/25gmmc/the_oklahoma_panhandle_is_less_than_two_miles_shy/
props again to /u/khosikulu
I might be late on this, but here is a long answer.
Originally Texas claimed a huge amount of land, but in 1850 was persuaded to give up its far western and northern claims. Congress paid Texas $10 million in stocks bearing 5% interest over 14 years, and Texas's panhandle and western borders were established. The Missouri Compromise, prohibiting slavery north of 36°30' N, west of Missouri, was extended west, making the northern border of the Texas panhandle.
Texas used to claim its border ran north along 100° W to the Arkansas River, and its western border was the Rio Grande. One problem was that the Rio Grande was the center of New Mexico's settlements. Congress decided on a border at 103° W and 32° S to separate Texas from New Mexico. All this gave Texas the shape it has today (minus a dispute over Greer County).
Later in the same year, 1850, New Mexico Territory and Utah Territory were created, along with the state of California. Originally the eastern border of New Mexico Territory ran up the Texas panhandle, along 103° W, continuing north all the way to 38° N (today NM and Oklahoma's northern border is 37° N). All the land due north of Texas, and reaching north to Canada, remained "Indian Territory", which was originally intended to be reserved for Indians (though by 1850 it was obvious that Indian Territory would be greatly reduced in size).
By 1850 a good number of Indian reservations had been established in Indian Territory, mostly in the eastern part of what is now Oklahoma and Kansas. Many of the reservations were for "removed" tribes, like the Cherokee, Creek, Choctaw, etc, but also tribes like the Shawnee, Osage, Miami, Kickapoo, etc.
A few years later, in 1854, Congress organized the bulk of Indian Territory into Nebraska and Kansas Territories. There were Indian reservations running from what is now Oklahoma north through eastern Kansas all the way to Nebraska. The borders of these reservations changed frequently. Two of the larger reservations were those of the Cherokee and the Osage. Their border ran west along 37° N, ending at 100° W (a bit north of the eastern border of the Texas panhandle). The western part of the Cherokee land was known as the Cherokee Outlet. It ended at 100° W.
When making Kansas Territory Congress decided to use the reservation boundary between the Cherokee and Osage, 37° N. But instead of ending at 100° W Congress continued the line west to New Mexico Territory, 103° (remember at the time NM extended north to 38°). So, between Texas, New Mexico Territory, Utah Territory, and Kansas Territory, and the established reservations of Indian Territory, there was a leftover strip of land north of the Texas panhandle that had no jurisdiction at all. This was what is now the Oklahoma panhandle.
The federal government came to call it the "Public Land Strip". It was commonly called "No Man's Land". It remained outside any state or territory until 1890. In the meantime various territories were created and borders adjusted until all borders were basically as they are now (although in 1890 Utah, Arizona, and New Mexico were still territories). In 1890 Congress created Oklahoma Territory, reversing its policy of reserving Indian Territory exclusively for Indians. The new Oklahoma Territory was at first cobbled together out of bits of land not then assigned to specific tribes (over time many reservations had been reduced in size), along with the Public Land Strip.
At first the Public Land Strip was disconnected from the rest of Oklahoma Territory and so still more a strip than a panhandle. In 1891 the Cherokee Nation agreed to extinguish its rights to the Cherokee Outlet, which lay between the strip and the rest of Oklahoma Territory. The treaty was ratified in 1893 and the old Cherokee Outlet added to Oklahoma Territory. It was at this point that Oklahoma truly gained its panhandle.
After that only the eastern part of what is now Oklahoma remained Indian Territory, and its destiny was becoming clear. In 1907 Indian Territory was incorporated into the new state of Oklahoma.
Source: American Boundaries, Bill Hubbard, Jr.; University of Chicago Press; 2009.
(edits for minor wording)
What does the word panhandle mean?