France's ruling Socialists said Sunday they won a key by-election, beating the far-right National Front candidate in President Francois Hollande's first major challenge since the Paris attacks.