A fused heterocyclic compound having an enteropeptidase inhibitory action and use of the compound as a medicament for treatment or prophylaxis of obesity, diabetes mellitus, etc., are provided.Specifically, a compound represented by the following formula (I):wherein each symbol is as defined herein, or a salt thereof and use of the compound as a medicament for treatment or prophylaxis of obesity, diabetes mellitus, etc., are provided.本發明提供稠合雜環狀化合物,該化合物具有腸肽酶抑制作用並作為用於治療或預防肥胖症、糖尿病的藥劑的使用等。具體而言,本發明提供以下式(I)代表的化合物或其鹽:其中各代號在本文中所定義,及將該化合物作為治療或預防肥胖症、糖尿病的藥劑的使用等。