What do the end of a trial in Egypt, a continuing trial in Tunisia and a trial that is just beginning in Yemen have in common?
Each demonstrates a turf war between old and new political forces in postrevolutionary countries, fought on the battlefield of the courts.
Start in Egypt, where in the past few days an extraordinary power struggle has been fought between President Mohammed Morsi and the independent public prosecutor, Abdel-Meguid Mahmoud.
Last week, 24 men were acquitted of planning the infamous "Battle of the Camel", when pro-Mubarak forces on horses and camels charged activists in Tahrir Square in early February 2011. As a Mubarak-era official, Mr Mahmoud was blamed for the controversial ruling and suspected of putting forward a deliberately weak case. He incurred intense public anger.
The case sparked the worst violent protests since Mr Morsi's election, and the president tried to remove Mr Mahmoud from his post and assign him as ambassador to the Vatican. Mr Mahmoud resisted, and on Saturday finalised a deal that allows him to remain in office.
On the face of it, this was a straightforward attempt by an elected representative to remove an relic of the old regime. But it was more complex than that. Had Mr Morsi succeeded, it would have set a destructive precedent, in which the head of the executive branch removed an ostensibly independent member of the judiciary.
The judiciary has a complex role in a nation with a long legal tradition. Under the Mubarak regime, the courts were heavily politicised but judges did fight to maintain their independence - in 2005, after Mubarak announced a presidential election, judges staged a revolt, refusing to oversee the election unless they were given legal guarantees of independence.
That decision was made by the Judges Club, an influential group of Egypt's top legal authorities. The same body backed the prosecutor general against Mr Morsi last week.
For good or ill, Mr Mahmoud is now embedded in the institutions of government. Regardless of his record, his office conveys legitimacy. It is important that the institutions of a new Egypt function - more important than any single case, even one where it was widely believed that the 24 men were guilty of a brutal attack on protesters. Institutions must inspire confidence.
The same applies to other institutions as well: on Sunday, the Nadim Human Rights Center in Cairo released a report finding that police had killed at least 34 people and tortured at least 88 during Mr Morsi's first 100 days as president. Those statistics indicate abuses comparable to those of the old regime.
Mr Morsi's move may have been pandering to populism, but there is a real question about how to change the institutions of law and order.
The same populism can be seen in Tunisia, where Prime Minister Hamadi Jebali recently declared two officers accused of raping a woman would be "severely judged".
Mr Jebali, of the Islamist Ennahda party, also probably intended to show that things had changed, that agents of the state were no longer above the law. The rape case is the first time that police officers have been charged for such an offence allegedly committed while on duty. Yet the officers have not stood trial, and may be acquitted.
The case has outraged many Tunisians, and has broad implications for women's rights. It is not, however, for the prime minister to decide in advance.
The most recent case comes from Yemen on Saturday, where lawyers representing families of protesters killed last year filed charges against former president Ali Abdullah Saleh and several members of his regime. The charges will prove a test case for Yemen's transition to an independent judiciary: can the legal system fairly try Mr Saleh, who still wields enormous influence in the political sphere?
In all three countries, two things are occurring at the same time. On one hand, there is the rebuilding (or the building for the first time) of legal institutions and the judiciary. Concurrently, there is a move to purge the old guard from power - including positions in the judiciary.
This presents a conundrum, as evidenced by Mr Morsi's actions and Mr Jebali's statement. They can claim political legitimacy delivered at the ballot box, but they run the risk of being too reactive to public opinion. If the centralisation of power made Mubarak too authoritarian, Mr Morsi faces a different risk of always being pushed by populist forces.
Even flawed institutions have some legitimacy and Egypt's judiciary, although packed with Mubarak-era judges, must be respected to a degree. The same goes for Tunisia's court system.
In Yemen, a functioning court system is absolutely vital, especially because the state is so weak. The result of the case against Mr Saleh will have a profound effect on Yemenis' confidence in the courts.
The Battle of the Camel, a rape case against two police officers and charges against ex-regime figures for murder: disparate trials that show the direction of Arab Spring countries. They demonstrate the shifting balance between different arms of the state, and the necessity that no single branch dominates.
It will always be popular to follow the people. But politicians, particularly those with long experience in exile, need to recognise that leading a nation means not putting what the people want today ahead of what the people will need tomorrow. Populist politics can easily unmake a nascent state.
On Twitter: @FaisalAlYafai