The organization of state administration in medieval Serbia was regulated by common laws, chrysobulls (charters) and translations of Byzantine civil and church laws. The first acknowledged written charters of the Serbian medieval state go back to the XII century.
The most distinguished written source related to the development of security-intelligence structures in the territory of medieval Serbia originates from the period of the Emperor Stefan Dusan Nemanjic's rule (from around 1308 to 1355). In that period of time "the Law of the godly Emperor Stefan" or the so-called Emperor Dusan's Code was adopted as the most significant legal document of that time, which had an important role in the historical development of the Serbian law, organizing of the state and regulating of social relations.
The first part of this Code (up to its 135 article) was enacted on the national assembly in Skopje, on May 21, 1349, on the Ascension Day (Spasovdan). Its second part (up to its 201 article) was codified on the national assembly in Ser in 1354, in the form of amendments.
According to the Dusan's Code, a kefalija (town chief) was one of the main carriers of the work corresponding to the present police and security-intelligence work. The kefalija was a town chief, district governor and duke in town in charge of both military and civil activities. With help of his associates he maintained law and order, secured law abiding, gave commands for preservation of order, forced court decisions, deployed road guards for travelers' security purposes, protected property, carried out investigations and determined factual circumstances, arrested and incarcerated suspects with aim to subsequently transfer them to court and, on certain occasions, he personally punished them. Kefalija had right to pronounce sentences for all the braches obstructing the established law and order.
Within the military and combined military-police competences, kefalija was in charge of the town fortresses maintenance and, in case of war danger, he would determine a common duty for all the citizens – duty to protect, stand on guard in cities and on roads (gradobljudenije), which was beyond doubt one of the most significant defensive and security measures.
The system of intelligence work was developed during the Emperor Dusan's rule, primarily with help of landowners in bordering areas (border landowners), but with help of spies as well (spies had crucial role in the battle of Velbuzd in 1330 and they examined in detail the arrangement of Turkish army forces in the battle of Kosovo in 1389). At that time great significance was attributed to the fight against the enemy spies (counterintelligence).