Board Thread:General Discussion/@comment-5398287-20130626022750/@comment-8986886-20130629233451

From what I get, Aizen had sent a team of Shinigami to steal the Hogyoku from Kisuke. On their way back they encountered Rangiku and Gin must have witnessed the assault, followed the Shinigami to where Aizen was hiding and discovered that he was their leader.

This is revealed during Gin's attempt to kill Aizen in ep307 at 17min and 21min and also ep308 at 5min and 8min.