"According to Spanish law, Ecuador and the rest of Spain's colonies were the personal property of the Spanish king. Thus, every law and deed in the colonies was carried out in the name of the king. In Spain, on the king's behalf, the Council of the Indies conceived all the laws that regulated life in the colonies and the House of Trade governed all trade and commerce between Spain and the colonies. In the colonies, the viceroyalty, audiencias and municipal councils administered law and trade.
Ecuador was part of the Viceroyalty of Peru ruled from Lima from 1544 until 1717, when it joined the newly created Viceroyalty of Nueva Granada ruled from Bogotá. In 1563, however, Quito became a Royal Audience of Spain, the Royal Audience of Quito or Quito Audiencia, thus permitting it to deal directly with Madrid on certain matters instead of going through the Viceroyalty in Lima.
The name Quito Audencia is misleading because it gives one the idea that the territory under the jurisdiction of Quito was comparable to the limits of the city of Quito today. In truth, the territory of the Quito Audencia greatly exceeded that of present-day Ecuador, encompassing the north of present-day Peru, the city of Cali in the south of present-day Colombia, and much of the Amazon River Basin east of present-day Ecuador. Quito also served as the most important municipal council within the area comprising modern-day Ecuador and as such was responsible for, among other things, the maintenance of public order."
Source