As the Brexit results poured in, I caught myself humming a tune from Broadway’s “Hamilton.” The song follows the decisive Battle of Yorktown in 1781, after which the Redcoats surrender and America is free. It’s called a drinking song, and there’s not much to it except these words: “The world turned upside down.”

It certainly has. The world is also coming full circle because now it’s the Brits who are free. It took them a while, but they finally had their own Tea Party and their own revolution.

I salute them for their courage. And I raise a glass to freedom (that’s “Hamilton,” too).

Revolutions are a leap into the unknown and require the right mix of outrage, determination and leadership. They are testament to the ethos of an entire country and culture when they succeed without a shot being fired.

That’s the beauty of Brexit, and of grand old England. The people spoke, they were heard, and the wheel of history is turning. Let’s get on with it.

It took a revolution because the leaders of both of Britain’s major political parties united in opposition to change, with the pooh-bahs and grandees trying to scare voters into sticking with the status quo. Naturally, the establishment media lectured the rubes on what was good for them.

Sound familiar, America?

Not surprisingly, Donald Trump encouraged and celebrated British independence, declaring that voters “took their country back.” Stuck on the wrong side of history, President Obama and Hillary Clinton acted as if their dogs died.

Fortunately, Prime Minister David Cameron set the right tone for the defeated by doing the honorable thing and saying he would resign. Because investors hate uncertainty, stock markets around the world took an immediate dive, but there were no riots, looting or arson and the sun set on schedule.

This is Western democracy in all its grandeur. It refreshes itself not with the blood of innocents, but with the peaceful passion of ordinary people. Raise another glass to freedom.

The parallels to America’s tumult are obvious — right down to the hairy similarities of Trump and mop-top Brexit leader Boris Johnson.

While the original Redcoats tortured rebels, killed their families and confiscated their lands, the new Redcoats in Washington and Brussels kill the spirit of innovation, enforce conformity with regulations and punish dissidents with charges of bigotry.

Elitists of both parties try to silence Trump by accusing him of “hate speech” for demanding that America control its borders and enforce its immigration laws. Similarly, Johnson was greeted with calls of “racist scum” first thing in the morning.

Johnson, potentially the next prime minister, committed the crime of suggesting that Great Britain would be greater outside the suffocating embrace of European Union bureaucrats. He favors a liberated country that can make its own laws and decisions, and put its own people first.

While not carbon copies of Trump’s rallying cries of “Make America Great Again” and “America First,” the sentiments come damn close. As does the growing fear in both countries that distant, self-serving governments are slaves to political correctness and are not doing enough to stop Islamist terrorists.

To be clear, Trump and Johnson are not sainted men of unquestioned virtue. Rather, they are leaders speaking on behalf of millions upon millions of middle- and working-class people who feel left out of the globalized economy.

In both countries, those who favor the status quo and those who want to upset it are divided by income, education and even geography. Just as Trump gets most of his support from those who are poorer and less educated, residents of booming London voted heavily to remain in the EU, while those in the rest of the struggling country voted more heavily to leave.

In both Great Britain and America, the well-connected people working in government, finance and other sectors that benefit from the international system have no idea why anyone would want to rock the boat. Yet the very trade agreements that mysteriously move money and whole industries and make them winners leave many individuals feeling like pawns in a global game they can’t control or even understand.

People who played by the rules and still became second-class citizens in their own countries have legitimate claims. When they try to express them through the political process, they are patronized and then ignored.

Wary of being demonized, many even are reluctant to confess their anger. As a result, just as polls in the US often undercount Trump supporters, British polls were way off in predicting that “remain” would win.

Now the secret is out, and millions of people in both countries are in open revolt against the encrusted establishment, economic as well as political. There will be setbacks because the road is complex and because change of the magnitude they seek can never be easy.

But they have begun, and it’s a thing of beauty to see such undaunted courage on both sides of the Atlantic. Count that bond as a special part of the special relationship.