Complex sentence: The gates had been closed and locked, but were quickly opened to admit him, and immediately closed again as he entered.
Split into simpler sentences: The gates had been closed and locked, but were quickly opened to admit him. Although the gates were immediately closed again as he entered.