Complex sentence: In both cases, they succeeded incumbent Prime Ministers who lost the support of their party caucus mid-term and their election as party leader preceded their predecessor's resignations and their subsequent appointments as Prime Minister.
Split into simpler sentences: In both cases, they succeeded incumbent Prime Ministers who lost the support of their party caucus mid-term. In the case of both Gillard and Keating their election as party leader preceded their predecessor's resignations and their subsequent appointments as Prime Minister.