On Friday, it looked as if Hillary Clinton’s Presidential campaign might be in big trouble. James Comey, the director of the F.B.I., announced that the bureau had found new evidence that might be relevant to the investigation into her e-mails. The evidence, it was soon reported, had surfaced on a laptop belonging to Anthony Weiner, the disgraced former congressman and estranged husband of Huma Abedin, one of Clinton’s closest aides. But, within a few days, the campaign had managed to change the subject from what Comey might find that Clinton had done to what Comey himself had done by making such a dramatic announcement less than two weeks before the election. Somebody mobilized a small army of congressional allies, letter-signing and op-ed-writing former high officials, and Sunday-morning-talk-show guests, all of whom offered severe critiques of Comey. Harry Reid, the Senate Democratic leader, went so far as to accuse Comey of violating the Hatch Act, the federal law that prohibits some high-level officials from engaging in political activity.

Clinton has built up a big lead—and seems likely to maintain it, despite Comey’s revelation—without anyone swooning over the brilliance of her campaign. She comes across in public appearances as being practiced but not inspiring, and released and hacked e-mails have shown us the “Veep”-like atmosphere inside her encampment. But, in her dogged way, she has progressed from having a factious and low-functioning campaign in 2008 to having a factious and high-functioning one in 2016. For the past sixteen months, roughly since Donald Trump’s insult of Senator John McCain (“I like people who weren’t captured”), the Republican Presidential nominee has been behaving in ways that were far outside the bounds of acceptable behavior for a Presidential candidate. For most of that time, it only seemed to make him more popular.

This changed with a series of events, beginning in the summer, that the Clinton campaign either orchestrated or exploited, and that caused Trump to become unhinged at a new, more self-damaging level. These were his conflicts with the federal Judge Gonzalo Curiel, with the parents of Humayun Khan, a Muslim-American soldier killed in Iraq, with the former Miss Universe Alicia Machado, and, finally, with the women who came forward to say that he had groped them. There’s a pattern here: Trump, who thinks of himself as a Seigneur surrounded by admiring and grateful servitors who call him “Mr. Trump” (at least until the moment when he tells them, “You’re fired!”), suddenly finds the social order reversed. The little people are attacking him, and he’s expected to grovel and beg for forgiveness. And that makes him blow up.

None of Trump’s sixteen Republican-primary opponents figured out that you ought to attack this particular aspect of his psyche. Hillary Clinton, or someone in her vast operation, did. The Khans were given an unexpectedly prominent role onstage at the Democratic National Convention. Clinton referred to Machado, in a way that obviously had been planned in advance, in her closing remarks at the first general-election debate, and the campaign followed up with supporting material. As each of the horror stories about Trump and women emerged, it took about ten seconds for it to become an active theme of the campaign. Throughout the past few months, on the stump and in the debates, Clinton was able to insert her banderillas expertly and with a smile of quiet satisfaction, and to get just the result she had apparently expected.

People in politics love to quote from Sun Tzu’s “The Art of War”; Clinton seems to exemplify its famous maxim that in order to win you have to know both yourself and your enemy. She realizes that she doesn’t have the spectacular political talent of her husband or of Barack Obama, and she makes up for it by being obsessively prepared and organized. You don’t come up with her anti-Trump strategy without having a lot of resources devoted to opposition research, polling, focus groups, and messaging. She also doesn’t have the conviction of her two Democratic predecessors that she can win over swing voters—or grandiose and ruthless heads of state or members of Congress—through mere charm or sweet reason or eloquence. Eight years ago, Obama’s political director told Ryan Lizza that when Obama interviewed him for the job, he remarked, “I think that I’m a better speechwriter than my speechwriters. I know more about policies on any particular issue than my policy directors. And I’ll tell you right now that I’m gonna think I’m a better political director than my political director.” That’s not Hillary Clinton.

Clinton’s biggest mistakes, like setting up her private e-mail server, spring from excessive fear and caution, rather than excessive confidence. She works hard and doesn’t give up. She attends to details. She doesn’t have an exaggerated sense of her own powers. She seems unlikely to believe that she can remake vast swaths of the world with one or two bold strokes, as George W. Bush did after the 9/11 attacks. And, as this summer and fall have shown, she can expertly defenestrate an adversary when the situation calls for it. None of this may thrill those of us watching her campaign, but these aren’t bad qualities in a Presidential candidate, or, for that matter, in a President. One of the main lessons of 2016 is that we could do a lot worse.