"Are you about to tell my story? Hold up. Let me go stare nobly into the distance."
He begins to tell the tale of how the dwarves of Erebor, led still by Thorin's grandfather Thror, tried to retake Moria from the orcs that had taken over. The movie flashes back to the Battle of Azanulbizar, where the dwarves defeated the orcs outside the gates of Moria. Balin, Dwalin, and Thorin are shown fighting. The orcs were led by Azog the Defiler, who takes it upon himself to end the line of Durin - starting by beheading Thror. Thrain, Thorin's father, goes missing, mad with grief. Thorin battles Azog personally; his shield rent, he picks up a branch of oak to use a shield, gaining the name Oakenshield. He chops off Azog's hand, and Azog is dragged back into Moria as the orcs retreat. Azog is assumed dead, the orcs are defeated, and the dwarves win. After the flashback sequence is over, we see a pair of orc warg-riders watching the dwarves from a distance. One tells the other to send word to their "master" that they have found the dwarves.
The Book: This scene never happens in The Hobbit, though the narration does make mention of the dwarves telling stories on their journey. There is no reason to assume that the Battle of Azanulbizar is not one of the stories they may have told, and that Bilbo may have heard. However, the Battle itself is not mentioned anywhere in The Hobbit. Also, there are no orcs chasing Thorin's company in the books - at all. I will discuss that in more detail in a later post.
Regarding the Battle of Azanulbizar, quite a bit is changed from "the book" (by which I mean, Appendix A.) III.) of the Lord of the Rings). For one, Thror was not killed at that battle. He was killed by Azog, but it was much earlier, when he went to Moria with only another dwarf. Thror was beheaded, and his body defiled, and his companion returned the head (and a small sack of coins) back to Thrain - who declared war. In other words, Thror's beheading caused the War of the Dwarves and Orcs, which the Battle of Azanulbizar ended.
This is like having Pearl Harbor and Hiroshima happen on the same day.
Thrain and Thorin were both wounded during the fight. Thrain did not leave yet (he led the dwarves for some time after this battle, before deciding to wander off to Erebor by himself), and Thorin did not personally do battle with Azog. Dain Ironfoot killed Azog, and the dwarves beheaded the vile orc and shoved a sack of coins in its mouth. Balin, Gloin, and Thorin are mentioned as participating in the battle. After the battle, the orcs retreated south (not back into Moria); it was Durin's Bane that kept the dwarves from retaking Moria for good.
Seriously, what, did you just fucking forget this thing was here or something?
What does it matter? Most of the details of the Battle of Azanulbizar are inconsequential - even the large ones, like Thror's beheading, or the retreat of the orcs back into Moria. It has no effect on the movie's story to get a few details of history wrong, and we know that the orcs end up back in Moria eventually. Streamlining these details helps keep the audience informed, in broad strokes, without slowing the pace to a crawl. The death of Azog should have also been more final, but like I said, that topic deserves a post of its own.
My Opinion: I'm very happy to see this scene in the movie. Not only was it entirely unexpected (not being a part of the book at all), but it was cool to see a bit of the history of the dwarves that earlier only existed in the appendices. Seeing Balin and Dwalin (with hair!) fighting in their youth was a cool touch, too. I do wish they had shown Dain, though. Even if they wanted to keep things personal between Thorin and Azog, Dain was an important player in this battle (and will be an important player in things to come).
A small detail, however, that I wish Peter Jackson had handled differently. The Battle of Azanulbizar was told to Bilbo by Balin. I would have liked to have seen another dwarf tell the tale. As much as I like Balin, he's just got so much characterization in the movie (The old warrior? Check. Thorin's second in command? Check. The legal expert? Check. The resident raconteur? Check.), that a lot of the other dwarves simply lack. Let another dwarf show some hidden depths by being a good storyteller. Maybe Gloin, or Dwalin, who were both present.