Complex sentence: In 1877 he became First Lord of the Admiralty (an appointment which gave rise to the character of Sir Joseph Porter, KCB, in Gilbert and Sullivan's operetta "HMS Pinafore"), holding this office for three years until the Liberals returned to power.
Split into simpler sentences: In 1877 he became First Lord of the Admiralty (an appointment which gave rise to the character of Sir Joseph Porter, KCB, in Gilbert and Sullivan's operetta "HMS Pinafore"). Smith held this office for three years until the Liberals returned to power.