Hathaway began appearing in dramatic roles after The Princess Diaries 2. She said that "anybody who was a role model for children needs a reprieve", although she noted that "it's lovely to think that my audience is growing up with me". She voiced Red Puckett in the animated comedy Hoodwinked! (2005), based on the Little Red Riding Hood folktale, which received mixed reviews by critcs. That same year, Hathaway starred in Barbara Kopple's drama film Havoc, in which she played a spoiled socialite, appearing nude in some of its scenes. Although the content of the film was different from her previous films, Hathaway denied that her role was an attempt to be seen as a more mature actress, citing her belief that doing nudity in certain movies is merely a part of what her chosen form of art demands of her; and because of that belief she does not consider appearing nude in appropriate films to be morally objectionable.
After Havoc, Hathaway was cast alongside Heath Ledger and Jake Gyllenhaal in Ang Lee's drama Brokeback Mountain (2005). While Havoc was not released in theaters in the United States because of its weak critical reception, Brokeback Mountain won rave reviews for its depiction of a homosexual relationship in the 1960s and received several Academy Award nominations. Hathaway would later assert that the content of Brokeback Mountain was more important than its award count and that making the film made her more aware of the kind of stories she wanted to tell as an actress.
In 2006, Hathaway appeared in David Frankel's comedy The Devil Wears Prada, in which she starred as an assistant to a powerful fashion magazine editor portrayed by Meryl Streep, whom Hathaway described as being "just divine". Hathaway said that working on the film made her respect the fashion industry a great deal more than she had previously, though she claimed that her personal style is something she "still can't get right". In an interview with Us Weekly, Hathaway discussed the weight loss regime she and co-star Emily Blunt followed for the film, she stated, "I basically stuck with fruit, vegetables and fish [to slim down]. I wouldn't recommend that. Emily Blunt and I would clutch at each other and cry because we were so hungry."
Hathaway was cast in the 2007 comedy Knocked Up, but dropped out before filming began and was replaced by Katherine Heigl. Writer/director Judd Apatow stated in a May 2007 issue of The New York Times Magazine that Hathaway dropped out "because she didn't want to allow us to use real footage of a woman giving birth to create the illusion that she is giving birth". In an August 2008 interview with Marie Claire, Hathaway commented that she "didn't believe that it was necessary to the story".
Hathaway was in the 2007 drama Becoming Jane, in which she portrayed English writer Jane Austen. Tim Burton considered Hathaway for the part of Johanna Barker in his 2007 film Sweeney Todd: The Demon Barber of Fleet Street, but the role went to Jayne Wisener, a then-unknown actress, reportedly because Burton decided he wanted an unknown, younger actress for the part.