Social democracy has its roots in Marxism. But it has distanced itself from Marxism.
In the 18th century and the first decades of the 20th century, social democracy was a broader movement that included Marxists. In 1863, the German social democratic party SPD was founded. It was one of the first Marxist parties. The SPD was co-founded by August Bebel and Wilhelm Liebknecht. Bebel believed that socialism could be achieved through legislation rather than bloody revolution. In 1871 election, German Social Democrats won 2 seats. In the 1912 election, the SPD becomes the largest party in Germany.
Social democracy begins to change after Eduard Bernstein's "The Preconditions of Socialism and The Tasks of Social Democracy". Unlike Marxism, he believed that capitalism was not doomed and that it could be used to improve workers' conditions. According to him, socialism could be achieved by electing socialist representatives.
When German dictator Hitler came to power in 1933, the SPD closed down and the party went into exile. After the end of the Second World War, social democratic parties began to govern some countries. They had some success, especially in the Scandinavian countries.