In almost every episode of The Office, Jim played a prank on Dwight, or at least he tried to. Though he has a 99.9 percent success rate with the hilarious pranks he pulls on the assistant to the regional manager, every once in a while, Dwight outsmarts the charming prankster.

RELATED: Every Character Who Was Added To The Show After Michael Left

Dwight is a supremely intelligent paper salesman, but he lacks common sense, so in the rare time when he does outsmart Jim, it’s a remarkable stride in character development that’s worth celebrating. Not only does Dwight beat Jim at his own game with pranks, but of the many times he’s tried getting Jim fired, he’s come dangerously close, several times.

“You Got Meatball’d”

Dwight and Stanley holding meatballs

The war between Jim and Dwight has inspired some hilarious memes, but every now and then, another vivacious member of Dunder Mifflin gets involved and picks a side.

The unlikely duo of Dwight and Stanley teamed up to make Jim believe that Stanley loves food-related pranks. So, as he loves an audience, Jim plays up to Stanley and fills Dwight’s drawers and cupboards with meatballs. Jim had been feeding them for weeks and it spawned one of Stanley’s best catchphrases, “You got meatball’d!”

Using Jim’s Credit Card To Buy Pam Flowers

Jim in The Office

In a bid to win Dwight’s Christmas bonus, after Andy told him that if either of them misbehaves, their bonus will go to the other person, Jim attempts to stitch Dwight up.

Jim gives his credit card details over the phone as loudly as he possibly can, with the assumption that Dwight will overhear and use those details for himself. Dwight uses the card details ... to send Jim’s wife flowers.

Erin Winning An Art Contest

Erin telling Pam she has won an art competition

Dwight is actually one of the few people who often supports Pam in her weakest hours, which is one of the reasons why he is a good guy, but he’s by no means perfect. In fact, Dwight, above anybody else in the office, has a vicious mean streak.

As Pam is an ambitious artist, Dwight encourages Erin to tell Pam she won an art contest. Dwight wasn't trying to upset Pam, but to get under her husband’s skin, and Jim played right into his hands.

Figured Out Jim Wasn’t On Jury Duty

Jim, Dwight, and Andy in The Office

Dwight’s hatred for time wasters is one of the reasons why he is arguably the better employee, and Dwight stopped at nothing to get to the bottom of Jim’s lie.

As Jim was only at jury duty for one morning, he used it as an excuse to get the next few days off, and Dwight expertly deduced exactly that. What then ensued was Dwight yelling and complaining to get Jim fired, which didn’t work that well, but he tried his best.

Public Speaking Tips

Dwight giving a speech

As Dwight won salesman of the year at Dunder Mifflin, it was up to him to give a speech at the annual event. Though it doesn’t seem like Dwight would be nervous, he sought public speaking advice from Jim, who of course, advised him to copy the grand speeches of Mussolini.

RELATED: The Office: The First 10 Employees To Leave Dunder Mifflin (In Chronological Order)

Though this was in jest, Dwight gave one of the most compelling speeches, which resulted in him getting a standing ovation from the audience.

Jim’s Backfired Infertility Prank

Dwight driving the work bus

As Dwight is the owner of the office space that Dunder Mifflin rents, he is responsible for actively upkeeping it.

As Jim wants a full paid week off work, he tries to convince Dwight that there is a radiator problem by popping a bag of popcorn and placing it under Dwight’s desk, making him worry that he might be turning infertile. But instead of getting a week off work, Dwight hires a very cramped work bus and forces Jim to work in it.

Frames Jim

Jim Halpert in The Office the job opportunity

Dwight came fairly close to getting Jim fired in one of his most malicious and dastardly schemes on the show which caused Jim to embarrass himself and his wife.

Dwight created an incentive scheme for sales agents and made Jim believe it was his idea. When Jim reads the results to the office, only to find out that he won, he suffers a huge backlash from the sales staff.

The Snowball Prank

Dwight's snowman army in The Office

What started out as just retaliation turned out to be one of the meanest pranks in the show. After Jim throws a snowball at Dwight, Dwight decides to come down on Jim with a vengeance and torments him in a way that Jim couldn’t possibly have imagined.

The psychological torment lasts for the whole episode, but the best part was at the very end, as Dwight filled the parking lot with snowmen and Jim believed Dwight to be hiding inside any one of them. This is the most fearful and insecure Jim has ever been, and as Dwight isn’t going to get Jim fired, this was the closest he ever came to defeating Jim.

Fires Jim And Pam So They Get Severance

Pam, Dwight, and Jim in The Office finale

In the final episode of the show, Jim and Pam try to quit their jobs at Dunder Mifflin, as they are finally moving on to better pastures. In their debriefing with the new manager, Dwight, he won’t allow them to quit. Instead, he fires them, so that they both receive huge severance packages.

It was one of the saddest moments of the finale - an emotional rollercoaster and the very last time that Dwight outsmarted Jim.

NEXT: The Office: 10 Characters You Totally Forgot Existed