A plush toy that’s come to life (voiced by Seth MacFarlane) shares some pillow talk with Mark Wahlberg and Mila Kunis in “Ted” — which is smarter than your average bear movie.

E.T., phone “Family Guy.” Maybe the magical little alien wouldn’t have been so adorable if he had hung around for 28 years trading raunchy remarks with Elliott while watching too much TV and smoking weed. But he would have been funny.

Yet the surprise of “Ted” is that it goes for honest Spielbergian wonder, too, and even earns some tears. Though you’ll be able to say that you were merely crying with laughter at the filthy jokes.

The ridiculously funny, outlandish and inventive first film directed by “Family Guy” creator Seth MacFarlane, who also co-wrote the screenplay, begins much like “E.T.” (and “Big”). After a lonely little Boston boy wishes his teddy bear were real, it starts walking and talking.

Cute idea, but MacFarlane advances it by imagining the bear as a celebrity who first appears on Johnny Carson — then becomes just another forgotten expersonality jaded by minor fame. Ted laments he might as well have made his name for being on “Diff’rent Strokes.”

As years go by, the bear (voiced by MacFarlane) is content to hang out with his buddy John (Mark Wahlberg) making wisecracks, but John’s girlfriend Lori (Mila Kunis) says the plush toy has got to move on, or she will. So Ted has to get his own apartment, put on a suit for a job interview (“I look like Snuggles’ accountant,” he complains) and get a job at a grocery store. Where he nails a cashier.

I expected “Ted” to be a one-joke movie, but it’s got ideas spilling out of its seams. It’s a smoothly designed rom-com, in addition to being a parody of same, and for a while it’s even bizarrely effective as a thriller. The banter between man and bear is nearly as sharp as the script of “Superbad.” “Ted” would work fine even if the stuffed animal were a human roommate.

As it is, the bear is such a believable character (thanks in part to brilliant CGI, and credit MacFarlane with deploying familiar technology with such an innovative spirit) that the scene when Ted beats up John isn’t really funny. Instead, it’s a little heartbreaking: You hate to see such good friends hurting each other.

Ted and John are like many a pair of buds who, when seen from a female perspective, bring out the child in each other. Plus, Lori is jealous at being left out of their shtick. She is frustrated when they have to explain a joke to her, and seethes when she finds out John’s ringtone for her calls is the Darth Vader theme. A gift for comedy is to men what a gift for style is to women: something they wish the opposite sex had a lot more of. And sometimes two guys’ shared adoration for a bad movie can be as powerful as any romance.

The movie runs short of imagination in the last 10 minutes, but until then it’s nearly perfect. Typically deft is a scene in which John, trying to win Lori back during her date with her wealthy but sleazy boss (the superb “Community” star Joel McHale) does something that is not only a big, funny gesture but is also sweet and yet gives Ted ample opportunities for dirty jokes. Even better: The boss may have a heart, too. He admits he slipped into jerk mode in high school and got stuck there.

I don’t know what MacFarlane can do to top this movie. Maybe Ted joins a frat with Paddington, Fozzie and Winnie the Pooh? Winnie’s honey pot will run dry as usual, but this time Ted could introduce him to his bong.