The present invention relates to cyclic indolizinecarboxamides and azaindolizinecarboxamides of the formulae Ia and Ib, wherein R, Ra, R10, R20, R30, R40, Y, n, p and q have the meanings indicated in the claims, which are valuable pharmaceutical active compounds. Specifically, they inhibit the enzyme renin and modulate the activity of the renin-angiotensin system, and are useful for the treatment of diseases such as hypertension, for example. The invention furthermore relates to processes for the preparation of the compounds of the formulae Ia and Ib, their use and pharmaceutical compositions comprising them.