I've had the same situation at Madrid connecting from BA to IB. BA flight landed late, so we ran to the gate which fortunately was nearby. Arrived with 25 mins to spare before departure with the aircraft doors still open to find a large number of also "late not late" people arguing with the gate agent. Turned straight around and went to the IB desk to rebook before there was a queue.