The present invention relates to a fused heterocyclic compound having an enteropeptidase inhibitory action and the use of the compound as a medicament for the treatment or prevention of obesity, diabetes and the like. Specifically, the present invention provides the compound represented by formula (I): [wherein each symbol is as defined in the specification. Or a salt thereof, and use of the compound as a medicament for the treatment or prevention of obesity, diabetes and the like.本発明は、エンテロペプチダーゼ阻害作用を有する縮合複素環化合物、及び前記化合物の肥満症、糖尿病等の治療又は予防のための医薬としての使用に関する。 具体的には、本発明は、式(I):[式中、各記号は明細書中で定義した通りである。]で表される化合物又はその塩、及び前記化合物の肥満症、糖尿病等の治療又は予防のための医薬としての使用に関する。