As heir-apparent to the throne, Denis was summoned by his father Afonso III to share governmental responsibilities. The country was again in conflict with the Catholic Church at the time, Afonso having been excommunicated in 1277, and only being absolved in 1279 when he acceded to Rome's demands on his deathbed. Consequently, the church was favorably inclined to reach an agreement with the new monarch upon his accession to the throne. In 1284, however, Denis emulated the example of his grandfather and father, and launched a new series of inquiries to investigate the expropriation of royal property; this was to the detriment of the church. The next year he took further steps against ecclesiastical power when he promulgated amortisation laws.These prohibited the church and religious orders from buying lands, and required that they sell or forfeit any they had purchased since the start of his reign. Several years later he issued another decree forbidding them to inherit the estates of recruits to the orders. In 1288, Denis managed to persuade
Pope Nicholas IV to issue a papal bull that separated the Order of Santiago in Portugal from that in Castile, to which it had been subordinate. With the extinction of the Knights Templar, he was able to transfer their assets in the country to the Order of Christ, specially created for this purpose. Denis was essentially an administrator and not a warrior king. He went to war with the kingdom of Castile in 1295, relinquishing the villages of Serpa and Moura. In 1297, he signed the
Treaty of Alcañices with Castile, which defined the current borders between the two Iberian countries, and reaffirmed Portugal's possession of the
Algarve. The treaty also established an alliance of friendship and mutual defense, leading to a peace of 40 years between the two nations. Denis pursued his father's policies on legislation and centralisation of power, and promulgated the nucleus of a Portuguese civil and criminal law code, protecting the lower classes from abuse and extortion. These edicts survived in the
Livro das Leis e Posturas (Book of Laws and Postures), and the
Ordenações Afonsinas (Alfonsine Ordinances), proclaimed during the reign of
Afonso V. These are not legislative "codes" as we understand them today, but rather compilations of laws and customary municipal law, as amended and restated by the Portuguese crown. As king, Denis travelled around the country to resolve various problems. He ordered the construction of numerous castles, created new towns, and granted the privileges due cities to several others. He declared in 1290 that 'the language of the people' was to become the language of the state, and officially known as
Portuguese. Denis also decreed that Portuguese replace Latin as the language of the law courts in his kingdom. His wife Elizabeth donated much of the large income generated by her lands and properties to charities, inspiring Denis to help improve the life of the poor and found several social institutions. The frequent procedural issues that arose when he issued his decrees increasingly occupied Denis in his quest to frame the common law as being within the scope of the crown's jurisdiction, and in exercising royal power in the realm. The restrictions he placed on the actions of
alvazis (local council officials), judges, as well as proctors and advocates in the courts, show that a merely nominal power of the monarchy over all the inhabitants of the kingdom, as was typical in the
Middle Ages, was not compatible with his effort to assert a royal prerogative to scrutinise legal procedures or moralise on the exercise of justice. The appointment of magistrates clearly marks the start of the process of the crown claiming territorial jurisdiction, thus expanding the royal domain, along with the growing importance of Lisbon as the nation's de facto capital. The preference for Lisbon as a venue of the royal court was accentuated during Denis's long reign. There was as yet no official capital of the country, but Lisbon's location, as well as its advanced urban, economic and commercial development, made the city the most viable choice for a national centre of administration. Its geographical situation between the ancient divisions of the country, i.e., the north and the south, enhanced Lisbon's status as the most practical centre for an emergent united Portuguese nation, the south now receiving as much royal attention as the north and becoming the residence of the monarchy. Their different characters created a realm where the two regions complemented each other. The great manors were closer together in the north, and the vast dominions conquered from the Muslims in the south, as well as the large areas of
unclaimed land there, expanded the domain of the crown, and much of the territory of the extreme south came under the control of the military orders. Denis promoted development of the rural infrastructure, earning the nickname of "the Farmer" (
o Lavrador). He redistributed land, founded agricultural schools to improve farming techniques, and took a personal interest in the expansion of exports. He set up regular markets in a number of towns and regulated their activities. One of his principal achievements was to protect agricultural lands from advancing coastal sands by ordering the planting of a pine forest near
Leiria, which also provided a source of raw materials for construction of a naval fleet. This forest, known as the
Pinhal de Leiria (Leiria Pinewood), still exists, and is an important conservation area. ==Later years and death==