Irving wrote The Sketch Book during a tour of Europe, and parts of the tale may also be traced to European origins. Headless horsemen were staples of Northern European storytelling, featuring in German, Irish (e.g., Dullahan), Scandinavian (e.g., the Wild Hunt), and English legends, and were included in Robert Burns's poem "Tam o' Shanter" (1790) and Bürger's Der wilde Jäger, translated as The Wild Huntsman (1796). Usually viewed as omens of ill-fortune for those who chose to disregard their apparitions, these specters found their victims in proud, scheming persons and characters with hubris and arrogance. One particularly influential rendition of this folktale was recorded by the German folklorist Karl Musäus.
During the height of the American Revolutionary War, Irving writes that the country surrounding Tarry Town "was one of those highly-favored places which abound with chronicle and great men. The British and American line had run near it during the war; it had, therefore, been the scene of marauding, and infested with refugees, cow-boys, and all kinds of border chivalry."
After the Battle of White Plains in October 1776, the country south of the Bronx River was abandoned by the Continental Army and occupied by the British. The Americans were fortified north of Peekskill, leaving Westchester County a 30-mile stretch of scorched and desolated no-man's land, vulnerable to outlaws, raiders, and vigilantes. Besides droves of Loyalist rangers and British light infantry, Hessian Jägers—renowned sharpshooters and horsemen—were among the raiders who often skirmished with Patriot militias. The Headless Horseman, said to be a decapitated Hessian soldier, may have indeed been based loosely on the discovery of just such a Jäger's headless corpse found in Sleepy Hollow after a violent skirmish, and later buried by the Van Tassel family, in an unmarked grave in the Old Dutch Burying Ground. The dénouement of the fictional tale is set at the bridge over the Pocantico River in the area of the Old Dutch Church and Burying Ground in Sleepy Hollow.
Irving, while he was an aide-de-camp to New York Gov. Daniel D. Tompkins, met an army captain named Ichabod Crane in Sackets Harbor, New York during an inspection tour of fortifications in 1814. Irving may have patterned the character in "The Legend" after Jesse Merwin, who taught at the local schoolhouse in Kinderhook, further north along the Hudson River, where Irving spent several months in 1809. The inspiration for the character of Katrina Van Tassel was based on an actual young woman named Katrina Van Tassel. Washington Irving stayed with her family for a short time, and asked permission to use her name, and loosely base the character on her. He told her and her family he liked to give his characters the names of people he had met. 
The story was the longest one published as part of The Sketch Book of Geoffrey Crayon, Gent. (commonly referred to as The Sketch Book), which Irving issued serially throughout 1819 and 1820, using the pseudonym "Geoffrey Crayon". With "Rip Van Winkle", "The Legend of Sleepy Hollow" is one of Irving's most anthologized, studied, and adapted sketches. Both stories are often paired together in books and other representations, and both are included in surveys of early American literature and Romanticism. Irving's depictions of regional culture and his themes of progress versus tradition, supernatural intervention in the commonplace, and the plight of the individual outsider in an homogeneous community permeate both stories and helped to develop a unique sense of American cultural and existential selfhood during the early 19th century.