The article examines the legal basis for ensuring the principle of inadmissibility of foreign interference in elections in Russia and Kazakhstan, and the practice of their implementation. It is noted that interference in national elections of foreign states is not a political novel of the last decades, and in the XX century it was quite a frequent phenomenon. The facts of foreign interference in the elections that took place in the Russian Federation during the post-Soviet period of its development are presented. In the 21st century, national elections and their results were often used, among other things, as a reason for a change of power. In this regard, the consolidation of guarantees of non-interference in elections in national legislation is one of the directions for the realization of the state sovereignty of any country. Guarantees of the principle of non-interference in national elections in Russia and Kazakhstan have been consolidated at the legislative level. They can be divided into two groups. The first group includes legal requirements related not only to elections, but also to other socio-political processes. In the article, they are considered on the example of legislation defining the procedure for the activities of mass media. The second group includes guarantees that have been enshrined directly in the national electoral legislation, in provisions relating to certain stages of the electoral process. The author notes that despite the fact that the mechanisms countering foreign interference in elections were included in the electoral legislation of Kazakhstan initially, the principle of "prohibition of foreign interference in elections" was consolidated only in 2022. The need for this was reflected in the Message of the head of state to the people of Kazakhstan dated March 16, 2022. Special attention is paid in the article to the comparative legal study of the institute of foreign agents, the process of formation of this institution in national legal systems is considered. In Russia, this institution appeared at the beginning of the last decade. The main purpose of its appearance is to ensure the national security of the state and reduce the possibilities of foreign interference in its internal affairs. Considering the history of this legal institution, the author notes that a new stage in its development was the adoption of Federal Law No. 255-FZ dated June 14, 2022 "On Control over the activities of persons under foreign Influence." In Kazakhstan, despite the formal absence of such an act, representatives of the expert community speak about the actual existence of the law on foreign agents. In conclusion, the author notes that the right of any State to establish the elements and content of the national electoral system, in the context of ensuring the implementation of the principle of inadmissibility of foreign interference in elections, should be determined by several criteria. On the one hand, the electoral system should be a means of reflecting the interests of voters and protecting the sovereign rights of the State. On the other hand, the restrictions imposed in order to protect it must be reasonable, proportional to external and internal challenges.