Citation inside a Caption – LaTeX

Recently while writing my thesis, I came across a strange error while compiling with LaTeX. The problem arose when I gave a cite command inside a caption environment. The caption was for a figure. For example
\caption{This is the caption for a figure. From  \cite{friend2005}}
This gave the following error:

! Argument of \Hy@tempa has an extra }.
<inserted text>
\par
l.89 ...sity estimate. From  \cite{friend2005}}

?
Runaway argument?
\@captype {\@firstoftwo {\@ifstar {\HAR@acite }{\HAR@fcite }}}\def \reserved@b
\ETC.
! Paragraph ended before \Hy@tempa was complete.
<to be read again>
\par
l.89 …sity estimate. From  \cite{friend2005}}
?
A little googling around I found this site which solved the problem in a second.
So the command should read like:

\caption{This is the caption for a figure. From  \protect\cite{friend2005}}

And the problem is solved. In case you are wondering what \protect does look here.