The film begins with Pete and Debbie having sex in the shower. Pete reveals that he took a Viagra given to him by his friend Barry (Rob Smigel); this enrages Debbie and they stop. Debbie is angered that she is turning 40.
In the five years since Knocked Up, Debbie owns a boutique with Desi (Megan Fox) and Jodi (Charlyne Yi) working for her. Pete owns his own record label, with his friends Ronnie (Chris O'Dowd) and Cat (Lena Dunham) working with him. Pete's business is struggling financially as he promotes the reunion of Graham Parker & The Rumour. The couple also are having to deal with their daughters; Sadie, a young teenager, and eight-year-old Charlotte. For Debbie's birthday, the couple goes on a romantic weekend to a resort. There they get high from eating marijuana cookies, and fantasize out loud about ways they would kill each other.
After speaking with her friends Jason (Jason Segel) and Barb (Annie Mumolo), Debbie decides to improve her marriage and family through exercise, and becoming more connected with her parents. Debbie tells Pete that he needs to stop lending his dad, Larry (Albert Brooks), money, because it is hurting them financially. Pete goes to visit him, but is unsuccessful at giving him the news, and still agrees to give him money. Meanwhile, Debbie visits her gynecologist (Tim Bagley), and discovers that she is pregnant. She decides not to tell Pete about this. Later, she yells at a student, Joseph (Ryan Lee), who has been taunting Sadie. She yells at him so much that his mother, Catherine (Melissa McCarthy), gets into an argument with Pete. They later have a meeting with the principal, but the couple denies everything that happened. The couple is overjoyed when Catherine starts using the same language they used previously and the principal dismisses them.
One night between the school taunting sequences, Debbie takes Desi out dancing at a club, planning to confront her with her suspicions that she has been stealing money from the store. Debbie and Desi meet several players from the Philadelphia Flyers hockey team at the pub. Debbie awkwardly finds out that one of the players wants to hang out with her and possibly sleep with her. She is proud that he wants to have sex with her, but admits that she is married, has two kids, and is pregnant. Afterwards, Debbie drops Desi off at her house and confronts her about the missing money. Desi reveals she is able to afford nice things because she is also an escort. Later, Debbie meets up with Jodi, who confesses that she stole the money to buy Oxycontin. Debbie fires her and leaves. Meanwhile, Pete and Debbie are having to deal with Sadie and Charlotte fighting all the time, which results in arguments between the family.
On Pete's 40th birthday party, he argues with his dad about the money he wants from them. Debbie argues with her dad about not spending enough much time in her life, and how his is perfect. Oliver then explains that his life is not perfect, and how he has always cared about her and loved her. Later, Pete overhears Debbie talking about her pregnancy, and rides out of the house on his bicycle in anger. Debbie and Larry then go after Pete, trying to find him. Soon, they find that he wrecked after hitting his head on a car door. Pete then gets into an argument with the driver of the car who then punches him in the stomach. Debbie and Larry take Pete to the hospital, where Larry and Debbie reconcile, with Larry advising Debbie that it's because of her, that she keeps the family together. Debbie and Pete talk later and Pete explains that he is actually thrilled about having a third baby, and that he doesn't feel trapped, so the two reconcile. Sometime later, Pete and Debbie are watching a small concert with Ryan Adams performing. Debbie then suggests that Pete should sign him to his label and plan to talk to him as they finish watching the show. After the main credits roll, there's an extended alternate take of Catherine ad-libbing insults during the conversation with Debbie, Pete, and the principal.

Question: Who gave Pete the Viagra?
Answer: Barry