Until 1904, Connolly was the leading figure in the Irish Socialist Republican Party. However, the ISRP had lost many members following internal disputes, with some forming the rival Irish Socialist Labour Party. The ISLP attempted to affiliate to the recently founded British Socialist Labour Party, but was advised to attempt to merge with the ISRP first. With Connolly out of the country, this was achieved, the two groups coming together to form the new "Socialist Party of Ireland". Although the party's initial membership was based in Dublin, it soon established groups in Belfast and Cork. However, it was unable to attract the Belfast-based members of the Independent Labour Party around William Walker to join, as they opposed the new party's principle of Irish Home Rule. Despite some growth, the party remained small and only held its first conference in 1910. Connolly was chosen as its national organiser, while Francis Sheehy-Skeffington became president, Michael Mallin was secretary, and William X. O'Brien was also elected to the executive. In 1912, Connolly called a socialist unity conference in Dublin, attended by the Belfast branch of the Socialist Party and four of the Belfast-based ILP branches, only Walker's own branch refusing to attend. The five groups united to form the "Independent Labour Party of Ireland", but this collapsed soon after the outbreak of World War I, after Connolly was banned from giving speeches alleged to be pro-German in Belfast by the local leadership of the group. Nationally, the SPI almost stopped operating during the war, but was revived by supporters of the Russian February Revolution and October Revolution. With the SPI now led by O'Brien, Cathal O'Shannon was elected as president, and Sean O'Casey also became a leading figure. An opposition faction around Roddy Connolly and Seán McLoughlin wished to affiliate to the Communist International. But even O'Shannon spoke about pursuing both political and military action to enable a workers' revolution, and welcomed the formation of the Communist Party of Great Britain. To build links with the Bolsheviks, both factions in the SPI claimed that the party had played a significant role in the Irish War of Independence. Although some members had been centrally involved, this claim was not correct, as the party was largely inactive at the time.
The left faction were successful in winning the group over, with Connolly becoming the leader and McLoughlin elected as president. Liam O'Flaherty and George Pollock also came to prominence, while O'Brien and O'Shannon were expelled in October, at the same time as the group renamed itself as the Communist Party of Ireland. Connolly wrote a document setting out a strategy for the party, arguing that it should develop a nucleus in the Irish Republican Army and the Irish Citizen Army, while also seeing revolutionary potential in the Protestant workers in Ulster. However, the Comintern ordered the party to focus on the national question and orientate to the IRA. While the CPGB was supportive of the CPI, it disagreed on this focus. Although the party claimed 300 members in October 1921, this dropped rapidly, and by the end of November, it claimed only 78 members in Dublin and 28 in Cork. In December, Nora Connolly and Eamonn MacAlpine were suspended and formed the rival Communist Groups, focusing more heavily on links with the IRA. The CPGB sent Thomas A. Jackson and Willie Gallacher to arrange negotiations between the two. The Anglo-Irish Treaty was signed in December 1921, and the CPI sided with the anti-treaty republicans; Peadar O'Donnell, a leading figure in the IRA, joined the party, and it formed a small Red Guard which offered to provide support for the IRA. O'Flaherty and Seán McIntyre led a small group of CPI members who declared that they were establishing a Soviet Republic while they occupied the Rotunda Hospital in January 1922, but the party's leadership called this a "childish stunt", and both leaders left Dublin and the party. The British Special Branch concluded that Connolly had visited Moscow on more than one occasion, and that the party was receiving a subsidy from the Comintern. They incorrectly believed that the party was responsible for numerous revolutionary actions early in 1922. At the 1922 Irish general election, the CPI endorsed O'Donnell's successful candidature in Donegal, although he did not sit as a party member. Patrick Gaffney, who had been elected for the Labour Party in the election, left it soon afterwards and joined the CPI, becoming its only Parliamentary representative. He stood again in the 1923 general election, but was heavily defeated. The CPI held its first Congress in January 1923, chaired by Walter Carpenter. Other than Gaffney, all the delegates were from Dublin. With membership remaining low, when Jim Larkin established the Irish Worker League in September, the Comintern ordered the CPI to dissolve itself, and for its members to work through Larkin's group. Although the party's leadership protested that membership would rise once imprisoned members were released, they complied with the order.