The 'lottery' in question is quite simple. The miners take as input
- The current state of the blockchain
Their own address (so that rewards can be awarded to them if they 'win')
(and this is the "lottery" part of it)
- A randomly chosen guess, or 'nonce' number. It can be any 32-bit number.
These three inputs are then fed into a hashing algorithm (specifically double SHA-256), which returns a (pseudo)random number.
If the result of the hash has a sufficient number of leading zeros, i.e. 0000001a34b16a... then the block can be added to the chain, and the reward is added to the miner's address.
In summary, miners guess random numbers, plug them into double SHA-256, and then repeat that process over and over again until somebody gets one that satisfies the above condition. Computers designed for mining are typically specialized hardware (such as ASICs, Application Specific Integrated Circuits) designed exclusively for running SHA-256 over and over.
The 'number of zeros' is actually variable, and is designed to control the 'difficulty' of mining a new block. More leading zeros required means more guesses required, and the condition automatically adjusts so that on average a block is added to the chain every ten minutes or so.