2009–2011: Breakthrough with Glee
In 2009, Rivera was cast as Santana Lopez, a high school cheerleader, on Fox's musical comedy series Glee, about a high school glee club. She auditioned for the opportunity "to sing, dance and act all in the same show", and because she was a fan of co-creator Ryan Murphy's previous work on Nip/Tuck. She drew on her own high school experience of unpopularity to prepare for the role, as well as watching films including Mean Girls to "really get in the zone and feel like a bitchy sophomore". Rivera described her character Santana as "a bit of a bad girl" and "your typical high school cheerleader, for the most part", saying that she enjoyed playing Santana because she "always has these really witty one-liners she throws out there". The LA Times wrote that Rivera was "woefully underused for much of Glee's first season", though Santana played a more prominent part in the last nine episodes of it; Rivera said at the time that "Santana's been wreaking havoc with people's boyfriends and people's babies and teachers – she's the high school terror, and she's going to continue to be the villain". Rivera continued as a nanny while working on the first three episodes of Glee, not knowing if they would bring her back; Murphy was so impressed by her that he "convinced the network" to contract her at this point.
After having her screen time and musical involvement increased in the second half of the first season, Rivera was promoted to series regular as of the beginning of the second season, something said to be earned because her "magnetism on screen was undeniable". She was given her first solo in the fifth episode of season two, "The Rocky Horror Glee Show", and performed several others as the season progressed. During the second season, Rivera's role in the show was radically changed when it was revealed that her character was a lesbian. Rivera portrayed Santana struggling to come to terms with her sexuality, with her love for her best friend, and with her inability to come out of the closet. Rivera spoke about the development of this aspect of her character, saying that it was first thought up by the writers as a "funny little thing" for a quick punchline; the actress pushed for the sexuality and relationship to be taken seriously. She received favorable reviews for her performance and is celebrated for the representation that Santana and her portrayal of the character provide; one feature on Rivera's legacy said that "in a landscape starved of representation, Santana was an oasis. A bold, well-rounded, hilarious woman of colour who was openly and unapologetically gay". In 2013, Santana's second season coming-out scene was described as "one of the hallmarks of the entire series". In relation to the show, Rivera was a guest mentor on The Glee Project's second season episode "Sexuality", and in January 2011, she appeared in a Funny or Die parody of "Nuthin' but a 'G' Thang", called "Nuthin' But a Glee Thang", which had been co-written by her Glee co-star Heather Morris. Rivera and Morris played girlfriends and ultimately wives on the show; Rivera said that the pair were comfortable filming intimate scenes, but that these became awkward because "all the guys wanted to visit the set". They remained close friends until Rivera's death.
In 2011, Rivera won her first ALMA Award for Favorite Female Music Artist; she won two more in 2012, in the categories of Favorite TV Actress – Leading Role in a Comedy and Female Music Artist. She received a great amount of critical praise for both her acting and her singing performances in the latter part of season two and the beginning of season three of Glee. As 2011 ended, she or her character were on many "Best Of" lists, including HitFix's 25 Breakout Stars of 2011, TV Guide's Best Performances of 2011, and MTV's Best TV Characters of 2011. In 2020, Santana appeared on the Thrillist list of the 100 Greatest TV Characters of the 21st Century, ranking at number 85 and the only Glee character included. In the third season, Rivera's character Santana was outed and began to publicly accept her sexuality, giving Rivera more complex and emotional storylines. She also performed a duet with Ricky Martin, and worked with Gloria Estefan, who was cast as Santana's mother. Estefan said that she studied Rivera's performance as inspiration for her own character, explaining: "I already knew [Santana] was very sarcastic, but [she] also has a heart, [...] So her mother had to be tough as nails, but with that little sarcastic edge", while also being supportive. Discussing Emmy nominations in 2012, Collider said that Rivera was "arguably the only bright spot" of the season. Study Breaks highlighted that while Santana had impactful storylines about her sexuality, she strayed from the "popular trope" of queer characters being defined by their queerness, as "she also stars in many other storylines in the show. The writers of Glee make it abundantly clear that Santana is a lesbian, but she is also a fierce, motivated dreamer who loves and loses like everyone else", with the article adding that her "firm sense of self goes beyond her race and sexuality".
As the 64th Primetime Emmy Awards approached in 2012, Rivera was listed by many critics and media outlets as deserving of a nomination; The Hollywood Reporter included her in their "Emmys 2012: Supporting Players" photoshoot, the annual class photo of the 25 top contenders across the various Supporting performance categories, and she was honored by media outlets like E!, HitFix, and TV Guide. She was chosen by the Television Academy to host the "Countdown to the Emmys" video for the then-upcoming awards ceremony, a video introduction to each year's ceremony that is watched by an estimated 25 million people. For the awards, Rivera submitted the Glee episode "Mash Off" for consideration in the Outstanding Supporting Actress in a Comedy Series category (an episode that had generated much Emmy attention) because it "was so well rounded. [Glee is] a comedy but [she] also got to show off some dramatic aspects of the character" in it. Despite this, Rivera was not nominated for an Emmy in 2012, nor in her career, with the media generally considering this a snub; The Daily Beast argued that she and other actors were overlooked because of their characters being young, while in 2020, Television Academy received criticism for years of Latin under-representation at the Emmys.