I'm not sure this will work for everyone but I had the same problem.
Instead of using the main character to fight the battle in the castle (before you head off to fight him on the top of the hill and get stuck in the gates) I used the secondary character Reem.
Amazingly it worked and I still ended up with the main character going off to fight on the mountain top and the gates opened.
Hope it works for those who are suck in the gates.
John
It´s 2020. I tried everything you explained here to avoid these bug: unequip the weapon, conquest the last castle with the secondary character... I´m still trapped between the two gates. I´ll write to Ubisotf support. There was a time Ubisoft means quality games.