Khatami accused hard-liners of undermining democracy and challenging the foundations of the Islamic Republic , which in theory is supposed to meld a democratic system with a theocracy carried out by clerical rule .