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