From the illustration shown at the ending credits of Final Fantasy XII, it can be deduced that both Basch and Gabranth were knights even in their younger days, probably before Landis was lost to the Empire.
Gabranth's loyalty arguably has always been with his homeland of Landis, even after he chose to seek refuge from the Archadian Empire and became a Judge. From his interactions with Basch and his interactions with other characters talking about Basch, it is clear that he still blames both Basch and himself for the fall of their homeland. Even though Gabranth staged Basch’s treason at Dalmasca’s treaty signing for the benefit of the Empire, and told both Vayne and Empire Gramis that he would slay his own brother for the Empire at different scenes early on in the game, in Gabranth's heart, these actions were probably acts of revenge and debt repayment for Landis.
Undoubtedly, Gabranth has also shown loyalty towards Emperor Gramis. After Gabranth relocated with his mother to Archades, it was due to gaining the favor of the Emperor that led him on the path to becoming a Judge and eventually a Judge Magister. Being the Judge that Emperor Gramis trusted the most, he was ordered to survey and report the actions of Vayne by the Emperor himself. Gramis also ordered Gabranth to protect Larsa and be his shield against Vayne before his eventual death at the hands of Vayne.
Loyalty was divided even amongst the Judge Magisters, with some Judges favoring Vayne as their master, while others favoring Emperor Gramis. After the death of Emperor Gramis, although Gabranth showed his loyalty to Vayne by being forced to kill Judge Drace, and followed his orders until the party fought with Vayne on the Bahamut, Gabranth was never truly loyal to Vayne. In the end, Gabranth decided for himself that he would serve Larsa as his master and sacrificed himself to protect Larsa from Vayne in the end.