Marx explains this question most thoroughly in his Critique of the Gotha Programme (letter to Bracke, 5 May 1875, which was not published until 1891 when it was printed in Neue Zeit, vol. IX, 1, and which has appeared in Russian in a special edition). The polemical part of this remarkable work, which contains a criticism of Lassalleanism, has, so to speak, overshadowed its positive part, namely, the analysis of the connection between the development of communism and the withering away of the state.
The State and Revolution · VI Lenin