How I Met Your Mother was a hit sitcom that sparked tons of different emotions. The show made audiences happy, it made them cry, but most importantly, it made people laugh. That was the sole purpose of the show, and it certainly did a great job at it.

With a core group of friends constantly hanging out at a bar, there was always going to be some amazingly funny moments. With tons of heart and emotion involved as well, the characters were able to create jokes that really meant something.

RELATED: How I Met Your Mother: 10 Of Barney's Most Inappropriate Pickup Lines

With lots of regular 'in-jokes' throughout the series, there were plenty of callback moments throughout the show, which was great for long-term fans. Of course, not every character was hilarious, but within this list, we will rank the main cast in order of their humor.

The Mother

Tracy in How I Met Your Mother

The basis of the entire show is the mystery mother is of the children Ted is telling the story to. While the way How I Met Your Mother ended angered most fans, Tracy, who was revealed to be the mother, wasn't a bad character at all.

Obviously, Tracy isn't featured in as many episodes as other characters due to the fact she isn't shown until later on in the show. Because of that, she does rank at the bottom of the list in terms of her humor in comparison to the rest of the main cast.

RELATED: How I Met Your Mother: Every Season Premiere, Ranked

Tracy might not have been as close as the rest of the group, but she certainly had no issues getting involved in-jokes with them. Tracy's relationship with Ted was a great one, and the two also shared many funny moments, it's just a shame she wasn't around earlier.

James

When James is introduced on How I Met Your Mother, the pressure is certainly on him to be a funny character. Because he is the brother of Barney, who is one of the funniest people, fans instantly expected James to be on that same level.

The writing team certainly did a good job of trying to bring similarities in their comedy style, but because he's not in the show that much he can't rank too high. His moments of being a wingman bring in some of the best moments on the show, as he is always funny in that environment.

Ted Mosby

Ted sitting on the couch looking sad on How I Met Your Mother

Look, the show might be all about him but that doesn't mean he has to be funny. While he certainly has many great moments on the show, he is not one of the funniest characters. His funniest moments tend to take place when he is drunk on the show, often leading to some brilliant moments.

RELATED: How I Met Your Mother: 5 Relationships Fans Were Behind (& 5 They Rejected)

However, Ted Mosby does dance a fine line between being loveable and being very annoying. There are many times throughout the show where he is just unwatchable, where he is needy and too attached to different females in his life.

In comparison to other characters on the show, he just doesn't hold up. Moments where he is talking to his children when he is meant to be funny, it doesn't end up landing, with Ted providing more of the serious and emotional moments.

Ranjit

Ranjit might not be in every episode of How I Met Your Mother, but he is certainly a regular feature throughout the show. He is always used for comedic purposes and very rarely gets placed into serious issues on the show, which is why he ranks so highly.

RELATED: How I Met Your Mother: The Best Episode From Each Season, Ranked

He has a great relationship with all of the main group, so when he appears he is able to bounce off them perfectly. His classic line of "Hellooo!" when he turns around from the taxi is always hilarious, and when he gets to drive the limousine it provides a great moment.

Robin Sherbatsky

Robin on How I Met Your Mother

Robin Sherbatsky is absolutely hilarious throughout How I Met Your Mother. She has a really witty and dry sense of humor, which is totally unlike anything else on the show and that is to her character's benefit. Being able to have lots of one-liners at the ready to fire back at people is always a great trait for a television show.

As well as that, she almost feels like one of the guys at times, which opens her up to a different style of comedy. Being able to really blend in as she works as a wing woman at some points, which leads to some hilarious scenes on the show.

Her Canadian background also creates some of the shows funniest moments. Even though a lot of the time it is Robin herself who is the butt of the joke, it still is hilarious.

Lily Aldrin

Lily on the phone in How Lily Stole Christmas

Just pipping Robin to the post, Lily Aldrin takes first prize for being the funniest female character on the show. In a similar way to her American Pie character, Alyson Hannigan did a brilliant job of being a little ditzy and crazy, while at the same time being loveable.

Her character was certainly more out-there than the rest, which allowed Lily to have a different style of comedy. Using various different jokes, Lily was able to always provide laughs constantly. Even if she could be incredibly silly, it worked perfectly on the show in a similar way to Phoebe on Friends.

On top of that, she was the most sexual of the main characters. While she played it innocently at times, it allowed the show to really add another layer to her character.

Barney Stinson

Barney at the bar in How I Met Your Mother.

When you think of How I Met Your Mother, Barney Stinson is likely one of the first characters that springs to mind. The main reason for that is because of how funny he is, with Neil Patrick Harris doing an amazing job with this role.

Of course, Barney is the ladies man of the show and that leads to most of his comedic moments. He is a smooth talker and whether he is on the prowl himself or trying to be the perfect wingman, Barney always has the right lines to say.

RELATED: How I Met Your Mother: Every Yellow Umbrella Appearance

He is able to bounce off all the main characters perfectly and has inside jokes with all of them. With his love of laser tag and suits also coming into some comedy gold, he really is a hilarious character.

Marshall Eriksen

Marshall at the bar in How I Met Your Mother

When it comes to the funniest character on How I Met Your Mother, Marshall certainly takes the top prize. Marshall combines so many different types of comedy that it is just impossible not to find him hilarious, especially since he is so consistent.

Whether it is physical comedy like his epic slap bet series with Barney, emotional comedy, or just having classic dad jokes, Marshall has it all. He always means well and is incredibly kind-hearted, which somehow seems to only make him funnier.

Throughout the show, he is constantly cracking up jokes and he doesn't need a catchphrase like Barney does to provide him with the material.

NEXT: 10 Things You Didn't Know About The How I Met Your Mother Song & Intro