Some well-established scientific findings may be rejected by vocal minorities because the evidence is in conflict with political views or economic interests. For example, the tobacco industry denied the medical consensus on the harms of smoking for decades, and the clear evidence about human-caused climate change is currently being rejected by many politicians and think tanks that oppose regulatory action. We present an agent-based model of the processes by which denial of climate change can occur, how opinions that run counter to the evidence can affect the scientific community, and how denial can alter the public discourse. The model involves an ensemble of Bayesian agents, representing the scientific community, that are presented with the emerging historical evidence of climate change and that also communicate the evidence to each other. Over time, the scientific community comes to agreement that the climate is changing. When a minority of agents is introduced that is resistant to the evidence, but that enter into the scientific discussion, the simulated scientific community still acquires firm knowledge but consensus formation is delayed. When both types of agents are communicating with the general public, the public remains ambivalent about the reality of climate change. The model captures essential aspects of the actual evolution of scientific and public opinion during the last 4 decades.