Recounts are essentially at the discretion of the Returning Officer (the person who oversees the election in each constituency). They use guidelines issued by the Electoral Commission. Candidates and their agents are entitled to request recounts. A Returning Officer must consider any recount request but may by law refuse it if they deem it "unreasonable".
This article is part of our Ask Full Fact series on the 2019 general election, answering your questions about the election, from claims the main parties are making to what happens on polling day.
You can see all the questions we’ve answered so far and we’ll keep adding to it as we get through them.