In 1665, Governor Richard Nicolls appointed Thomas Willett as the first mayor of New York City. For 156 years, the mayor was appointed and had limited power. Between 1783 and 1821 the mayor was appointed by the Council of Appointments in which the state's governor had the loudest voice. In 1821, the Common Council, which included elected members, gained the authority to choose the mayor. An amendment to the New York State Constitution in 1834 provided for the direct popular election of the mayor. Cornelius W. Lawrence, a Democrat, was elected that year.

Prior to the establishment of the office of Mayor of New York in 1665, New York was run by Richard Nicolls, who was the British military governor of the Province of New York. Thomas Willett was the first person to be specifically appointed Mayor of New York City.

More Info: en.wikipedia.org