Disagreement between scientists drives scientific progress. We propose a new theoretical understanding of disagreement and a methodological framework to identify instances of disagreement in scientific texts. After validating its robustness, we use this framework to quantify the extent of disagreement in the text of over four million publications in the Elsevier ScienceDirect database. The amount of disagreement differs across fields, and is highest in social science and humanities fields. Authors are more likely to disagree with older papers, and less likely to disagree with their own papers. This approach offers a new way of identifying and understanding disagreement across science.