How Trump has weighed in, or not, on 2017 elections

Until Tuesday, the president mostly stayed away from Democratic wins.

"Ed Gillespie worked hard but did not embrace me or what I stand for," Trump tweeted Tuesday night.

The president claimed a string of successes in special elections throughout the year, but has also been quiet in races in which it appeared that his influence could hurt the Republican candidate or Democrats were on a clear path to victory.

Here's a look at how Trump has weighed in on major races throughout 2017:

Virginia governor

While Trump never campaigned for Gillespie, Vice President Mike Pence appeared on the candidate's behalf in October

New Jersey governor

Utah's 3rd Congressional District

Alabama Senate primary

"I might have made a mistake, I’ll be honest," Trump said at a September event for Strange.

He further made a prediction about the media's reaction to a possible Strange loss.

"If Luther doesn't win, they're not going to say we picked up 25 points in a very short period of time. They're going to say, 'Donald Trump, the president of the United States, was unable to pull his candidate across the line. It is a terrible, terrible moment for Trump. This is total embarrassment.'"

Moore ultimately defeated strange 54.6-45.4 percent and Trump focused his response on the progress Strange made because of his influence.

Georgia's 6th Congressional District

At first, with 11 Republicans in the field, Trump avoided endorsing a particular candidate and admitted that the party was playing for a runoff. After Handel advanced, he engaged in an all-out onslaught against Ossoff and visited Georgia for a Handel fundraiser.

Ossoff managed to cut into the typical Republican margin of victory in the district, but Handel won the seat 51.9-48.1 percent.

South Carolina's 5th Congressional District

California's 34th Congressional District

Montana's at-large congressional district

In Montana, where the GOP held the state's single congressional seat for the past two decades, Trump had little to say until after the election. Many campaign observers believed that Democrat Rob Quist stood a decent chance of flipping the seat formerly held by Interior Secretary Ryan Zinke, particularly after Republican Greg Gianforte was charged with assaulting a reporter the day before the election.

While Quist was able to improve upon Democrats' performance the preceding November, Gianforte won the state by slightly more than 6 percentage points. Trump's tweet after the election did not name Gianforte -- who would later plead guilty to the assault charge -- but rather attacked the media for its coverage of the race.

Kansas' 4th Congressional District

Republican Ron Estes won the race in Kansas' deep-red 4th Congressional District in April. He received one tweet from Trump on the day of voting, with the president calling the candidate a "wonderful guy." Democrat James Thompson came closer to winning than any Democrat in over 15 years, but still lost by over 6 percentage points.