As depicted in the film, Gandalf appeared to be shaken and in fear of the Balrog of Morgoth, even just as Saruman mentioned it. Why was this so? Did they have any previous encounters?
Why would Gandalf be afraid of the Balrog? Well, it's a Balrog. It's a fearful thing. :)
More seriously, though, the Balrogs were terrifying beings, even for Gandalf and others of his level of power. The Balrogs are Maia as well, just as Gandalf and the rest of the Istari are. See here from the Valaquenta, the second book of the Silmarillion:
For of the Maiar many were drawn to his splendour in the days of his greatness, and remained in that allegiance down into his darkness; and others he corrupted afterwards to his service with lies and treacherous gifts. Dreadful among these spirits were the Valaraukar, the scourges of fire that in Middle-earth were called the Balrogs, demons of terror.
Not only are Balrogs on the same scale as Gandalf, they were beings of terror and fire to begin with, while Gandalf, for all his power, wasn't a warrior. He is described as "Wisest of the Maiar", and as a servant of Manwë, and of Nienna, and of Lórien, the Valar of wisdom and judgement and mercy and dreams, and not of Tulkas or Oromë, the more warlike Valar.
Additionally, you have to remember that in Tolkien's cosmology, older is always better. The world is always in a state of decay. The wonders of the Valar when the world was new could never be exceeded even by the greatest works of the elves in the First Age. Even Feanor's Silmarils were but an echo of the light of the trees. Likewise, the hands of Man of the Third Age could never produce works as fine as the Smiths of Eregion in the Second Age, and certainly not of the works of Feanor himself.
So keeping that in mind, we remember that the Balrogs were the Captains of Morgoth during the wars of the First Age. It took all the might of Ecthelion, Lord of the Fountain and one of the greatest captains of Gondolin and elvendom to defeat Gothmog, lord of the Balrogs, and he took him with him to his death.
So when Gandalf heard that a Balrog still lurks in the depth of Moria, of course he would be afraid. A Balrog is a terror of the First Age. And something that was a threat in the First Age would be an unstoppable terror in the Third.
Something that Avner's answer doesn't mention:
While Balrog and Gandalf are both Maiar, they are different ones:
Balrog still has a full power of a Maiar
Gandalf is in a mortal form, very deliberately stripped of most of his power, as his role was not to fight Sauron but to advise Men and Elves on the fight.
Gandalf < Olorin- independently of how Olorin the Maia compares to Balrog the Maia.
I have no reference handy, but in the movie at least it was implied that Gandalf knew we would die if he went to Moria. Having foreseen his death, the Balrog surely seemed to be the cause. It reflects his great courage that he went to Moria anyway, and that he stood against the Balrog to buy the others time, though he knew it was suicide.
We don't know the entire history of Gandalf. But he does know how powerful and dangerous Balrogs are - probably more so than most other beings in ME. I suspect it was nothing more than a realisation that here was a foe worthy of him.
He would have known of the Balrog's presence as it was "Durin's Bane": the dwarves delved too deep and awoke the Balrog that drove them from Moria in the first place. Also I think it's said somewhere that Manwe forbade the Istari to go to Middle-Earth clothed in power to fight against Sauron but to inspire the peoples of Middle-Earth to unite.
not all maia are created equally (and even less so then all vala)...for instance, gandalf was not keen on his mission to contest the will of sauron, because he was afraid of him (sorry, can't remember the page i am referencing), and he (olorin...one who dreams alone) took the assignment reluctantly...much like the other reluctant heroes in the book: frodo (apacifist who does not seek heroism, aragorn, who second-guesses his choices, sam, who is armed only with his loyalty...tolkien's message seems to be that the meek shall inherit (or at least save) the earth. gandalf is probably an older primordial spirit than is the balrog, but his role is t o encourage rather than to fight...he sacrificed himself for the company, because he had faith in the plan of Iluvatar to not reject his creation. For that faith, he was returned and exalted.
Gandalf would probably have known about the Balrog, however, he had forgotten things before In the course of the story. He didn't remember Isildurs writings about the inscription until years after he knew of the Ring. Remember that, in the book at least, he even helped Bilbo on his way by adding a flash to his disappearance at the long expected party? So how do we know that he didn't just forget this as well? After all, I can't remember my homework from yesterday if I tried, imagine how much harder it would be at his age!
Gandalf had seen a vision that we would die at the hands (hooves?) of a balrog. The warning that he would meet his end at Moria became an obvious intersection when he realized a balrog was coming.