When President Trump flip-flopped on legislation renewing Section 702 of the Foreign Intelligence Surveillance Act Thursday morning, he demonstrated embarrassing ignorance. When House Minority Leader Nancy Pelosi, D-Calif., flip-flopped on that same issue, she showed brutal opportunism.

It was a busy morning.

The president began his day by undermining a coordinated and lengthy effort between his administration and congressional lawmakers in support of the bill. An hour later, he changed his mind. Like most of this presidency, that stream of consciousness played out on Twitter and it proved too much of a temptation for Pelosi to overlook.

Pointing to the president’s ignorance, Pelosi reportedly begged Speaker of the House Paul Ryan, R-Wis., to pull the bill, before giving an impromptu floor speech about the dangers of tyrannical government, and then finally threw her support behind the bill at the last minute. Before lunch, Pelosi appeared to change her mind at least three different times.

Spinning that fast makes one invulnerable. Pelosi knows this because Pelosi has done this before.

Five years ago, Rep. Justin Amash, R-Mich., tried muzzling the National Security Agency and clawing back its domestic surveillance capabilities. Pelosi played both sides until the last vote was tallied. She privately rallied middling Democrats to join the war hawk wing to defeat the measure, while publicly urging the Obama administration to enact its own civil liberty safeguards to pacify her progressive flank.

"Had Pelosi not been as forceful as she had been, it’s unlikely there would’ve been more Democrats for the amendment,” an aide explained. In the end, 111 Democrats and 94 Republicans voted to kill the Amash measure by a narrow vote of 205-217. As Foreign Policy Magazine pointed out at the time, that political skill saved the NSA.

And now Pelosi has done it twice. The very same amendment that she defeated in 2013, she destroyed again in 2018. It failed 188-233 this time.

From Trump’s tweets to the final vote, the whole episode took about four hours. All at once, Pelosi managed to preserve NSA surveillance power, appear sympathetic to privacy concerns, and ding the president. It was a masterful and deceitful political performance.