We introduce twisted Steinberg algebras over a commutative unital ring R. These generalise Steinberg algebras and are a purely algebraic analogue of Renault's twisted groupoid C*-algebras. In particular, for each ample Hausdorff groupoid G and each locally constant 2-cocycle σ on G taking values in the units R × , we study the algebra A R ( G , σ ) consisting of locally constant compactly supported R-valued functions on G, with convolution and involution “twisted” by σ. We also introduce a “discretised” analogue of a twist Σ over a Hausdorff étale groupoid G, and we show that there is a one-to-one correspondence between locally constant 2-cocycles on G and discrete twists over G admitting a continuous global section. Given a discrete twist Σ arising from a locally constant 2-cocycle σ on an ample Hausdorff groupoid G, we construct an associated twisted Steinberg algebra A R ( G ; Σ ) , and we show that it coincides with A R ( G , σ − 1 ) . Given any discrete field F d , we prove a graded uniqueness theorem for A F d ( G , σ ) , and under the additional hypothesis that G is effective, we prove a Cuntz–Krieger uniqueness theorem and show that simplicity of A F d ( G , σ ) is equivalent to minimality of G.