The present invention provides a heterocyclic compound represented by the following formula (I), which has a glucagon antagonistic action and is useful for the prophylaxis or treatment of diabetes and the like, a compound represented bywherein ring A is an optionally substituted benzene ring and the like Y is a nitrogen atom and the like X is -O- and the like R4 is a hydrogen atom and the like R5 and R6 are each independently a hydrogen atom and the like R1 is an optionally substituted hydrocarbon group and the like R2 is a hydrogen atom and the like and R3 is -(CH2)3-COOH and the like, or a salt thereof.