The mayoralty is a global institution, existing on every populated continent and dating back centuries.
In Canada, we've had mayors since before we were a country.
A 1793 British statute enabled the appointment of local officials as "a corporation to represent the whole inhabitants of the parish or town." In 1849, the Baldwin Act (the blueprint for local government in Canada today) stated that in cities and towns these local heads would be called mayors. They were to be selected from within council for a one-year period. Their duties were: presiding over meetings, calling special meetings, and administering oaths. When Canada became a country a few years later, in 1867, we already had a community of mayors.
Canada's Constitution doesn't recognize a local level of government. Instead, "municipal institutions" are the responsibility of each province. As a result, local government - and the role of the mayor - has evolved somewhat differently in each province. Today, every province has legislation which outlines the role of the mayor. There are important differences across provinces. Interestingly, the duties shared by all mayors in all Canadian provinces and territories remain remarkably consistent with those laid out in the Baldwin Act in 1849.