Gatekeeper is an extension of the quarantine features first implemented in Mac OS X 10.5-10.7. When you download files using certain applications a quarantine bit is set (more on that in a second) When you open a file Launch Services looks for that attribute. If its set, it informs the user that the program was downloaded from the Internet and asks if they still want to run it. Gatekeeper also checks developer certificates against a blacklist.”]
Source: https://securosis.com/blog/os-x-10.8-gatekeeper-in-depth