In 2012, Sen. Sherrod Brown faced more than $24 million in ads from conservative groups opposing his first reelection.

Six years later, the Democrat has been forgotten as outside groups have almost entirely abandoned the Ohio airwaves, vastly improving his chances to win a third term in November.

Brown’s comfortable position comes as something of a surprise given President Trump won Ohio by more than eight percentage points in 2016.

But a new study, by a Republican strategist, suggests it should not be a surprise at all. Bruce Mehlman, a former Bush administration official, surveyed the past 10 midterm elections — covering 333 Senate races dating to 1978 — and discovered that Brown’s standing is actually the norm for a midterm election. And it is all because of Trump.

“The single most important factor is whether your party occupies the White House. If you are out of power and an incumbent, you just rarely lose,” said Mehlman, now a partner at a bipartisan lobbying firm.

Consider other Senate Democrats in similar states. Brown is one of five running in a state Trump won by single digits. Four other members of the Democratic caucus are seeking reelection from states Trump narrowly lost.

Of those nine contests, Florida is the only toss-up, according to independent handicappers.

Republicans are trailing in the other races, at this point, reducing the amount of defense Democrats will have to play this fall.

For certain, it is still a difficult climate for Democrats. They are defending five seats in states where Trump won by a minimum of 19 percentage points two years ago and remains relatively popular. In Florida, which Trump won by just one percentage point, Democratic Sen. Bill Nelson is in a dogfight against GOP Gov. Rick Scott.

And Republicans are defending only two seats, in Nevada and Arizona, where Hillary Clinton was competitive in 2016. They potentially face tough contests in Tennessee and Texas.

All this followed a historical set of races two years ago, in which all 36 states holding Senate races went in the same partisan direction as that state’s presidential ballot.

This created the potential for Democrats to suffer big losses in 2018, putting Republicans near the elusive figure of 60 seats and a filibuster-proof majority.

Democratic senators such as Brown, Robert P. Casey Jr. (Pa.), Tammy Baldwin (Wis.) and Debbie Stabenow (Mich.) might have seemed ripe for at least very strong challenges when Trump was sworn in in January 2017, coming from states that voted twice for Barack Obama and then gave Trump the margin to win the presidency.

Instead, Democrats are in control of those races and appear to have minimized their potential losses to a seat or two, with the outside chance of running the table to win the majority.

Sen. Chris Van Hollen (Md.), chairman of the Democratic Senatorial Campaign Committee, said these senators will support Trump in some areas — Brown’s trade policy aligns with the president’s in some respects — but they are openly campaigning on how they will “be an independent senator” for their state.

“That means being a check on Trump when necessary,” Van Hollen said.

History suggests that Trump’s triumph provided the key boost to their chances of victory in November, and Mehlman’s analysis reveals how the longest of long shots, a Democratic wave big enough to claim the majority, might not be unfathomable.

Since the 1978 midterm elections, 23 incumbent senators have run for reelection from a state a president from the other party had won two years earlier by single-digit margins.

The Senate incumbent from the opposition party has won all 23 contests.

That is the sort of historical reassurance that helps Nelson, Brown, Casey, Baldwin and Stabenow, who hope to extend that streak to 28 for 28 in November.

Trump’s sustained unpopularity in these states has freed up these incumbents to be more forceful in their challenges to the president. Casey, for example, announced his opposition to any Supreme Court nominee of Trump’s several hours before the president announced Judge Brett M. Kavanaugh as his pick. Stabenow waited a couple days but rejected Kavanaugh without even the courtesy meeting with the nominee.

But what about those five Democrats from big-time states supporting Trump? History is much kinder than anyone would have expected, according to Mehlman.

Since 1978, 43 senators have run in midterm elections in which a president of the other party won their state by more than 10 percentage points just two years earlier.

And 39 of those senators have won, almost 91 percent of them.

Think Sen. Susan Collins (R), who coasted in 2014 despite Obama’s easy victories in Maine. Or then-Sen. Kent Conrad’s easy reelection in 2006 two years after George W. Bush carried North Dakota by more than 25 percentage points.

This year’s Senate races will put that math to the test perhaps like never before, with Sen. Joe Manchin III (W.Va.), for example, running as a Democrat in a state where Clinton received just 26 percent of the vote two years ago.

And yet, according to Politico, the top GOP super PAC canceled a $750,000 ad buy set to run over the last half of July in West Virginia, a sign that maybe Manchin is in a stronger-than-expected position.

Republicans face a mixed bag in terms of states in which they are playing defense. Sen. Dean Heller (Nev.) is the only GOP incumbent running in a state that went for Clinton, by a slim margin, and incumbents running in those circumstances have won less than 70 percent of the time.

In Arizona, where Trump won by single digits and Sen. Jeff Flake (R) is retiring, history is not kind. The party holding that open seat, in a state its president narrowly won, has prevailed just 30 percent of the time.

It is almost as if Senate races have tilted into two different geographical maps. In presidential years, incumbents need to line up with whoever their state favors for the White House.

In midterms, not so much.