Provided is a substituted spiropyrido[1,2-a]pyrazine derivative or a pharmaceutically acceptable salt thereof, which is useful as an anti-HIV agent. The present invention relates to a compound represented by the following formula [I] or [II] or a pharmaceutically acceptable salt thereof: wherein each symbol is as defined in the specification.