A trap for capturing animals comprising: bait compartment with: side openings, and mobile enclosure element movable to selectively open and close side opening; guard compartment under bait compartment and comprising: guard roof with first hole in front part, and housing for receiving and retaining animals from bait compartment; closure panel, on guard roof, with second hole in rear part and which is movable in an anteroposterior direction between a position wherein second panel hole is in rear position and a position wherein it is in front position over a first hole; longitudinal actuation means to move closure panel and comprising longitudinal element movable in an anteroposterior direction; control circuit to control movement of closure panel, together with sensor activable by entry of an animal; mobile enclosure element being connected to a longitudinal element to cover or leave its corresponding opening open.