The emergence of quantum mechanics