In the actual incident during the American Civil War, William Scott, a private in the 3rd Vermont Infantry, fell asleep while on guard duty. He subsequently was arrested, court-martialed, and sentenced to be shot. Lincoln heard about the case, pardoned Scott, and returned him to his unit. William Scott was actually standing before his firing squad when the death sentence and pardon were both read, however no one had told him that he had been pardoned. Scott later died in at the Battle of Lee's Mills.
The "Sleeping Sentinel" was a melodramatic poem written about this case. In the film, Lincoln happens upon the scene while riding in a carriage, stopping the squad just before it fires (which never happened).
- Sleeping Sentinel at IMDB