This article analyzes the historical and theoretical foundations of the relationship between legality and expediency, examines international experience, and examines the dominance of formal legality in Russian practice. Measures to resolve this contradiction are proposed: developing a legal culture, establishing an institution of positive administrative discretion, and codifying criteria for deviating from formal regulations in a resolution of the Plenum of the Supreme Court of the Russian Federation.