James Ramsay MacDonald ( 12 October 1866 -- 9 November 1937 ) was a British politician and Prime Minister of the United Kingdom three times . James Ramsay MacDonald , PC , FRS ( 12 October 1866 â '' 9 November 1937 ) was a British Labor politician , who served two separate terms as Prime Minister of the United Kingdom .