The alguacil served as the sheriff of a Spanish municipality. He also acted as executive officer of the courts, the equivalent of a modern bailiff, and executed the decisions of the alcalde, or local judge. The alguacil could gain his office in a number of ways. Though in some towns he was elected, usually an alguacil was appointed to the position, either by the alcalde, the governor, or the ayuntamiento, the town council. The alguacil was a member of the ayuntamiento and had a vote equal to the other councilmen. He also had numerous duties, most of which consisted of acting upon the orders of the governor, alcalde, and ayuntamiento and serving as chief constable. As the principal police officer, the alguacil and his assistants, or tenientes, were allowed to carry arms as they patrolled the town. In addition, the alguacil maintained the security of the prison, if one existed. To avoid possible conflict and interference with his position, the alguacil could not hold another office or have a business. Instead, he received a percentage of the judgments he executed for his duties as administrative officer of the alcalde's court. The exact amount varied and was never standardized. In some areas he was also paid based on his number of arrests. The alguacil did not receive a fee for collecting fines owed to the royal treasury. The Spanish Constitution of 1812 and the subsequent independence of Mexico, which transformed many colonial institutions, did not substantively alter the alguacil's position.