Every day, the very first activity in the Temple was terumat ha-deshen – removing ash from the altar. The Mishna on our daf teaches that only one of the kohanim would merit this responsibility; the decision as to who would perform this service was based on a payis – a lottery. The Mishna describes the preparations that were made prior to the lottery:
Anyone who desired to remove the ashes from the altar used to rise early and immerse in the ritual bath before the appointed priest came. At what time did the appointed priest come? He did not always come at the same time; sometimes he came just at the call of the rooster, sometimes a little before or a little after. The appointed priest would come and knock and they would open for him, and he would say to them, let all who have bathed come and draw lots. Then they conducted the lottery and whoever won the lottery had the privilege of removing the ashes.
The history of this lottery, which was the first of four that were performed in the Temple every day, is described in some detail in Massekhet Yoma (daf 22 and daf 23). At first the kohanim organized a contest of sorts to determine who would merit the service of the terumat ha-deshen, but after it became clear that this led to dangerous and unfortunate situations, a lottery was instituted.
The lottery was arranged as follows:
Members of the priestly family that was performing the service would gather in a circle around the appointed kohen who was appointed to perform the lottery. He would instruct them to each put out a finger. He would then remove the hat of one of the kohanim and announce a number that he had chosen (the Rambam rules that the number was chosen by the participants) that was larger than the number of kohanim participating in the lottery. He would begin counting fingers from the kohen whose hat was removed until he reached the number that had been chosen. That kohen would perform the terumat ha-deshen.