My purpose in this essay is to clarify the notion of explanation by computer simulation in artificial intelligence and cognitive science. My contention is that computer simulation may be understood as providing two different kinds of explanation, which makes the notion of explanation by computer simulation ambiguous. In order to show this, I shall draw a distinction between two possible ways of understanding the notion of simulation, depending on how one views the relation in which a computing system that performs a cognitive task stands to the program that the system runs while performing that task. Next, I shall suggest that the kind of explanation that results from simulation is radically different in each case. In order to illustrate the difference, I will point out some prima facie methodological difficulties that need to be addressed in order to ensure that simulation plays a legitimate explanatory role in cognitive science, and I shall emphasize how those difficulties are very different depending on the notion of explanation involved