Specifically, for the rebels to win, you need to have (I think) at least 1.5x the CS in the capital as what the loyalists have. You can also win if the ruler steps down, is captured, is killed, or leaves the realm.
The loyalists, IIRC, need to hold out for 5 days or remove the rebel leader (and similarly, if the rebel leader leaves the realm, the rebels lose).