For some time, political observers have wondered — or feared — whether a major terror attack on American soil could sweep Donald Trump into the White House.

The topic came up after the mass shooting at the Pulse nightclub in Orlando back in June. And in the wake of a new series of bombings and attempted bombings in New York City and New Jersey, and a stabbing attack in Minnesota, the question of what effect terror could have on the presidential campaign once again seems urgent.

Both candidates have wasted little time speaking out on the matter. Trump quickly blamed what he characterized as the Obama administration's weakness and immigration policies for the attacks, saying in a Fox News appearance Monday, "We've been weak, our country's been weak, we're letting people in by the thousands, the tens of thousands. I've been saying we've gotta stop it." And he added that in addition to the refugees President Obama has allowed into the country so far, "Hillary Clinton wants to increase what he's let in."

Clinton, meanwhile, emphasized her foreign policy experience and tried to characterize Trump's extreme language as counterproductive in combating terrorism. "I'm the only candidate in this race who's been part of the hard decisions to take terrorists off the battlefield," Clinton said in a press conference Monday. She added, "The kinds of rhetoric and language that Mr. Trump has used is giving aid and comfort to our adversaries."

Yet commentators have tended to disagree about how the aftermath of an attack is likely to play out. On the one hand, political scientist Norm Ornstein suggested to me that attacks could greatly improve Trump's poor prospects of winning, and Politico’s Blake Hounshell tweeted in March that "America may be one major terrorist attack away from Donald Trump as president."

On the other, Trump is an erratic celebrity with no foreign policy experience, and the public could well instead turn to Hillary Clinton, as Jamelle Bouie, Greg Sargent, and Ross Douthat have argued.

So earlier this year, I spoke with several top political scientists who have done research on this question, and reviewed their work to see what implications heightened fears of terror tend to have on voters.

And according to Jennifer Merolla, a political scientist at UC Riverside who has long studied how terrorism impacts voters, her research suggests there's more reason to believe Trump would benefit than that Clinton would.

"On average, our findings suggest Trump may be advantaged," Merolla told me back in April. (Though she hastened to add that, due to the experience discrepancy, "Hillary Clinton may not be as disadvantaged as other Democrats.")

"Whenever terrorism is in the news, one way people cope with their anxiety and anger is to look for a leader to protect them"

Trump’s biggest strengths on the terror issue are that he is a member of the more hawkish party, he uses more aggressive rhetoric, and he may be perceived as a "stronger leader." Plus, sadly enough, some research indicates that even his gender could be an advantage over Clinton when voters’ fear of terror is high. So in a vacuum, there are many reasons to expect Trump to benefit.

"Whenever terrorism is in the news, one way people cope with their anxiety and anger is to look for a leader to protect them — and, in a crisis context, to rescue them," Merolla said.

Still, in many ways Trump of course isn’t a typical Republican candidate, and that he might not benefit to the same degree that ordinary Republicans might.

In July, political scientists Bethany Albertson and Shana Kushner Gadarian made the case in Vox that Trump's lack of expertise and his generally unpopular policy proposals on terrorism would give the advantage on the issue to Clinton. Their experimental research found that voters are more likely to be convinced by politicians that offer solutions rather than politicians who mainly hype threats. (Of course, it is also possible that voters may become persuaded that Trump's proposed ban on Muslim immigration is a "solution.")

Trump is also far more likely to use intemperate and extreme rhetoric than the typical candidate, which could turn off voters. For instance, after the Orlando shootings, Trump conspiratorially implied that President Obama may sympathize with the attackers. "The problem is that Trump is kinda this animal that doesn’t behave how people running for president usually behave," Michael Koch, a political scientist at Texas A&M University, told me in April.

Of course, every terror incident has its own specific circumstances, and we can’t know whether any particular one will strike a chord with the public in any particular way. It's also hard to disentangle effects any one event might have on the polls — Clinton's lead over Trump did drop by a few points in the weeks after the Orlando shooting, but other topics were in the news too, like the FBI's announcement on its investigation into her emails and Bernie Sanders's then-refusal to endorse Clinton.

"It depends on the details, and on how these things are spun," Koch, speaking when the question was still hypothetical, said. "But especially if you could spin it as a Democratic failure, or link it to failures of the Obama administration, it might advantage Trump."

And that’s just what Trump is trying to do.

The partisanship factor: Terror attacks often help the more hawkish party

Perhaps the biggest reason to expect that Trump's support would rise after a terror attack is, simply, the party he belongs to.

Polls consistently show that more Americans trust the Republican Party to effectively deal with terrorism than the Democrats. For instance, a Pew poll earlier last month gave Republicans a 9-point advantage on the question of which party would more effectively deal with "the terrorist threat at home." (Forty-six percent of respondents thought the GOP would do a better job, and just 37 percent thought Democrats would.)

Furthermore, both experimental and real-world studies have tended to show that in the US and abroad, the major party with a more hawkish reputation usually benefits when international terror becomes a major concern.

"Evaluations of President Obama’s job performance at worst suffer, and at best are unaffected, when people are worried about terrorism"

For instance, Koch, Laron Williams, and Jason Smith studied how quickly various parliamentary governments lost their majority coalitions after transnational terrorist attacks in a 2012 paper. What they found was that right-leaning governments had an easier time holding on to power than left-leaning governments did. It seems the left gets more blame for terrorist attacks that occur under its watch.

Then there's evidence from Israel that indicates that terror helps the right at the ballot box. Claude Berrebi and Esteban Klor found that a terror attack in an Israeli locality shortly before the election causes, on average, "an increase of 1.35 percentage points on that locality’s support for the right bloc of political parties." And Anna Getmansky and Thomas Zeitzoff found that after rockets are fired into areas of Israel, even if there are no casualties, support for right-wing parties spikes in those areas by 2 to 6 percent.

Finally, you might think the "rally 'round the flag effect" — the idea that public approval of the incumbent shoots up when terror becomes a major issue, as occurred for George W. Bush after 9/11 — could benefit Democrats, since they're the party that holds power right now.

Yet Merolla and Elizabeth Zechmeister have found evidence suggesting that Democrats, as the more dovish party, wouldn't necessarily get that boost. In a 2013 paper, they looked at both survey data comparing times when terror fears are high with times when they aren't, and findings from a lab experiment "priming" only some subjects with the topic of terror. "We find consistent evidence that evaluations of President Obama’s job performance at worst suffer, and at best are unaffected, when people are worried about terrorism," they concluded.

Now, there are occasional examples that cut the other way. The Spanish elections of 2004, three days after the Madrid train bombings, seem to have hurt the right and swept a left-wing challenger party to power. These do appear to be the exception, though.

The "leadership" and charisma factors

Though Donald Trump has closed in on Hillary Clinton in polls lately, he remains extremely unpopular among the public — he's the most unpopular major party presidential nominee in decades of polling.

Still, Trump's outspokenness and bluster do appear to have accomplished something important — they've convinced many voters that he's "tough."

Two polls earlier this year, for instance — from CBS/New York Times, and ABC/the Washington Post — show Trump and Clinton essentially tied on the question of which would be a stronger leader. A third, from Fox News, found Trump heavily advantaged on the question compared with Clinton — 59 percent of respondents in that poll thought he was a "strong leader," compared with just 38 percent who thought he wasn't. (Clinton's split was 49 to 50.)

"Charismatic leaders surface in times of crisis because they are seen as saviors"

Merolla and her colleagues have found that when a terror threat looms, this question of "leadership" becomes paramount. In three experimental studies involving three different elections between 2004 and 2008, they found that when undergraduate subjects were primed to think about the threat of terrorism (by either viewing a short video or reading an article), they were more likely to say they'd vote for the candidate they viewed as a better "leader."

"Crisis situations evoke feelings of distress, anxiety, and hopelessness, which draw citizens to leaders who promise to deliver better times," Merolla and her co-authors have written. "Charismatic leaders surface in times of crisis because they are seen as saviors and are perceived to have a unique ability to improve a critical situation."

Furthermore, in a 2004 study, psychologist Florette Cohen and several co-authors found that if subjects were spurred to think of their own mortality, they then said they'd be more likely to support a hypothetical politician with a charismatic leadership style — one who stresses the importance of bold risk-taking as well as "vision" and "identity of the group." Sound familiar?

In Cohen’s study, this "charismatic" leader is contrasted with a hypothetical "task-oriented leader" whose strengths are about effectively achieving goals, and a "relationship-oriented" leader whose strengths are "treating followers compassionately and respectfully" — both of which have often been used to characterize Hillary Clinton’s style of leadership.

When people are thinking about their own deaths, they apparently have little time for such niceties.

The gender factor

When fears of terrorism and death come into people's minds, all sorts of primal feelings can come with them. And Merolla says gender stereotypes might be among them.

"We’ve done some work on what effect terrorism has on evaluations of female candidates," Merolla told me. "And in some of that work, we’ve found that Democratic female candidates are particularly disadvantaged when terrorism is in the news. Because of party stereotypes and gender stereotypes, they're perceived as being weaker."

In a study conducted in 2005, Merolla and two co-authors again primed terror fears for certain groups of undergraduates. They asked whether their subjects believed that "[m]en make better political leaders than women do," and found that those who viewed a brief presentation about terrorism were more likely to say they did.

The researchers went on to ask respondents what they thought of various political figures — but the results didn't show a simple sexist swing. On the Republican side, both George W. Bush and Condoleezza Rice were viewed more favorably when terrorism was primed. Yet on the Democratic side, views of John Kerry didn't change all that much — but views of Hillary Clinton became sharply worse.

But the news isn't all bad for Clinton here. Keep in mind that this was before she served as secretary of state — so it's possible that it was mainly her relative lack of experience, not sexism, that explains the different effects for her and Kerry here. (Kerry had, after all, served in the military and had been his party's presidential nominee.)

Indeed, Merolla told me that she and her colleagues conducted a similar follow-up study in 2012, after Clinton had gained foreign policy experience. "We have not published this result yet, but we do not find the same negative effect on Clinton as we did in our earlier study," she says. (She did, however, find a negative effect on views of Nancy Pelosi.)

Still, perceptions of Clinton didn't significantly improve, either — Clinton didn't get the same boost that Bush or Rice did in the earlier study.

Trump thinks the issue will work in his favor

Now, there are limitations to studies like Merolla's — they take place in an artificial lab setting instead of the far more complex real world, and the usual subjects (undergraduates) aren’t representative of the electorate as a whole.

Still, they are bolstered by that real-world evidence that terrorism often benefits the right politically, like the studies of Israel and parliamentary governments.

Furthermore, if merely bringing up the possibility of terrorist attacks is enough to produce these effects in a lab among liberal-leaning undergraduates, the response to an actual attack in the country could well be even more pronounced.

The bigger drawback is, unavoidably, that Trump’s uniqueness as a candidate gives us very little precedent for evaluating how his singular features — his erraticism, his penchant for conspiracy theories, and the fact that he's never held political office — could help or hurt him.

Still, to be confident that Trump wouldn't be helped by a terror attack, you basically have to assume he's not an ordinary Republican candidate and that the electorate won't view him as such. Even though, since he’s clinched the nomination, the polls have gotten closer and the vast majority of GOP voters have fallen behind him.

And keep in mind Michael Koch's comments that "if you could spin it as a Democratic failure, or link it to failures of the Obama administration, it might advantage Trump." That’s just what Trump is trying to do, painting President Obama’s failure to condemn "radical Islam" as emblematic of a deeper refusal to be "tough" enough to protect Americans.

What has happened in Orlando is just the beginning. Our leadership is weak and ineffective. I called it and asked for the ban. Must be tough — Donald J. Trump (@realDonaldTrump) June 12, 2016

Again, no one can say for sure how the politics of the New York attack, or any possible future attack, will play out. Perhaps the simplistic solution of an immigration crackdown that Trump is peddling will in fact prove popular. Or perhaps the public will be repelled by Trump's conspiratorial rumblings that Obama might be sympathetic to the terrorists.

Still, the underlying research here suggests it certainly could have the potential to be a perilous moment for the Clinton campaign — if Trump’s own shortcomings don't hold him back.

This article was originally published in June. It has been updated to reflect recent events.

Watch: The political science that predicted Trump's rise