In 1985, in a suburb south of Boston, John Bennett (Bretton Manley) is a lonely kid, who dearly wished for his new Christmas gift, a large teddy bear he names Teddy ("Ted"), to come to life to be his best friend. The wish succeeds with a falling star and Ted (Zane Cowans) became a fully mobile sentient being. John's parents Joe (Ralph Garman) and Gina (Alex Borstein) got over the shock, word of the mareacle spread, and Ted was briefly a celebrity.
In 2012, John (Mark Wahlberg) and Ted (voiced and motion captured by Seth MacFarlane), now living in the South End neighborhood of Boston, are still staunch, if immature, friends enjoying a hedonistic life, even while John is pursuing a 4-year-long relationship with a level-headed office worker named Lori Collins (Mila Kunis). As the 4th anniversary of their relationship approaches, Lori hopes to marry John, but she feels that he can't move ahead with his life with Ted around, who's now a dirty, vulgar, obnoxious wastrel. John is resistant to kicking Ted out, but he is finally persuaded that night to act when he and Lori discover Ted at home with four prostitutes, one of whom has defecated on the floor during a game of Truth or Dare.
Soon, John finds Ted his own apartment and a job at a grocery store, where his grossly irresponsible behavior on the job manages to get him both promoted and acquainted with the superficial co-worker Tami-Lynn (Jessica Barth). Ted and John still spend most of their time together, which frustrates and irritates Lori when she discovers John has been skipping work to do so while using her for his excuses. Meanwhile, an obsessed stalker named Donny (Giovanni Ribisi), who idolized Ted as a kid, shows interest in possessing him for his brutishly destructive son Robert (Aedin Mincks). Things start to come to a head when Lori and John are invited to a party put on by Lori's lecherous manager Rex (Joel McHale), who has a crush on her against John, who wishes he would die from Lou Gehrig's disease; but Ted lures John away to a wild party at his apartment with the offer to meet Sam Jones (playing himself), the star of their favorite movie Flash Gordon. Although John arrives with the intention of spending only a few minutes, he gets caught up in the occasion which gets completely out of control, with Sam persuading John and Ted to snort cocaine with him and Ted singing karaoke. Eventually, Lori discovers John there and breaks up with him in a rage. At that, John blames Ted for ruining his life and tells him to stay away.
Eventually, Ted and John confront each other about their ruined friendship in John's hotel room and have a destructive brawl after John provokes Ted by saying he wished he got a Teddy Ruxpin instead of him, but soon manage to reconcile after the TV falls on John's crotch. To repair John's relationship with Lori, Ted arranges with an old lover named Norah Jones (playing herself) to help by having John express his love for Lori with a song during her concert, being held at the Hatch Shell. Although John's performance proves an embarrassment, Lori is touched by the attempt while repelled by Rex's sneering. Later, Ted goes to visit Lori at her apartment and explains that he was responsible for John's lapse; however, he offers to leave them alone forever if she goes to at least speak with him. Lori is persuaded, but moments after she leaves, Ted is kidnapped by Donny and taken to his house to function as Robert's victim.
Ted manages to distract Robert and reach a phone to contact John, but is soon recaptured. Realizing that Ted is in danger, John and Lori manage to find Donny's residence and chase him and Robert to rescue Ted. The chase leads to Fenway Park, where Robert tries to stop John and Lori from getting to Ted first, only to have John knock him out. During the chase, Ted gets himself damaged and just when Donny gets ahold of him on the tower, Ted falls onto the field, torn completely in half. A police car arrives, forcing Donny to flee. As John and Lori gather his stuffing, Ted relays his wish that John be happy with Lori, as the magic that gave him life fades away.
Unable to accept Ted's death, John and Lori return to her apartment to try to repair him, but it proves useless. That night, Lori wakes up and quietly makes a wish on a falling star. The next morning, Ted is magically restored and the trio fully reconcile with Ted, who encourages John and Lori to resume their relationship.
With that resolution, John and Lori are married and Ted comfortably accepts having a life of his own. One afternoon, Ted was caught behind the deli counter eating potato salad on Tami-Lynn's bare bottom and it got him somehow promoted to grocery store manager.