NEW HAVEN — If you were casting the title role of “Hamlet,’’ chances are Paul Giamatti would not be your first choice. Or your fifth. Or your fiftieth.

Short, balding, paunchy, 45 but looking older, Giamatti is about as far from the heroically dashing Laurence Olivier model of the melancholy Dane (who is supposed to be a university student, remember) as it is possible to be.

Yet here he is, starring in Yale Repertory Theatre’s “Hamlet,’’ directed by James Bundy. What this production has going for it is the fact that Giamatti is, quite simply, a great actor. It’s ultimately not enough.

His portrayal of Hamlet reaches a white-hot intensity at times, and he generally succeeds in capturing the prince’s pulverizing despair and the wheels-within-wheels workings of his grief-addled mind. But the production as a whole just doesn’t hold together.

The problem is not Giamatti’s clowning, of which more later, or the obvious issue of cognitive dissonance: that this Hamlet appears to be roughly the same age as his mother, Queen Gertrude (Lisa Emery), and his uncle, King Claudius (Marc Kudisch), or that he seems more than twice as old as his ostensible onetime beloved, Ophelia (Brooke Parks).

No, what plays havoc with the equilibrium of this “Hamlet’’ is that Giamatti seems to be performing in a different play than the rest of the cast. Hamlet appears to have only the slightest acquaintance with his supposed best friend, Horatio (Austin Durant), and his mother, and Ophelia. While a sense of apartness and alienation is obviously key to Hamlet, we should not feel, as we do in the “Get thee to a nunnery” scene with Ophelia, that the two are virtual strangers.

With a couple of exceptions, the cast lacks Giamatti’s fluency with Shakespeare’s language, creating a disjointed tone. Whenever the star and his manic energy are offstage, Yale Rep’s “Hamlet’’ goes slack.

Giamatti’s appearance on the University Theatre stage, of course, is freighted with significant personal history. He graduated from Yale College and the Yale School of Drama, and his father, the late A. Bartlett Giamatti, served as president of Yale.

In casting Paul Giamatti so decidedly against type, Bundy, Yale Rep’s artistic director, seems to have decided to underscore the actor’s Everyschlub persona rather than try to camouflage it. So this Hamlet wanders through stretches of Act 1 in a plaid bathrobe and blue boxer shorts, looking like an escapee from “One Flew Over the Cuckoo’s Nest.’’ Later, Giamatti is jauntily tricked out in a dinner jacket and red high-top sneakers. These quirky touches coexist uneasily with a production that otherwise proceeds in straightforward fashion within the imposing castle at Elsinore, handsomely designed by Meredith B. Ries.

The opening-night audience clearly had trouble at first buying Giamatti as a tragic figure. They laughed when Hamlet, attired in a dark business suit, made his first appearance, walking sullenly across the stage in the middle of a peroration by Claudius. They tittered when Giamatti muttered his first line (“A little more than kin, and less than kind,’’ a caustic assessment of his relationship with his uncle that is not really a knee-slapper) and again when he described Claudius as his “father’s brother, but no more like my father than I to Hercules.’’ It’s a mark of Giamatti’s skill that from that point on, the audience only laughed when he wanted them to — which was pretty often.

Bundy and Giamatti, who were students together at the Yale School of Drama in the 1990s, apparently took their cues from Hamlet’s warning early in the play to Horatio, as he begins to hatch a plan to revenge his father’s murder by Claudius, that the prince will henceforth “put an antic disposition on.’’

So Giamatti’s Hamlet mugs and capers and at one point even leaps into the arms of Horatio, wrapping his legs around his friend’s torso. At the end of an exchange with Polonius (a fine and funny Gerry Bamman), Hamlet dramatically pretends to cut his own throat. The director and his star will doubtless take some flak for these broad touches, but they struck me as mostly legitimate expressions of Hamlet’s disintegrating mental state, where the line between pretending to be mad and being driven mad gets blurry.

Of course, it is in the darker moments that we glimpse that state most fully. When Giamatti’s Hamlet declares that “this goodly frame, the earth, seems to me a sterile promontory,’’ it is with the air of a man who realizes that he faces a choice — to act or not to act, to bend a phrase — within a cosmos that really doesn’t give a damn.

BostonGlobe.com complimentary digital access has been provided to you, without a subscription, for free starting today and ending in 14 days. After the free trial period, your free BostonGlobe.com digital access will stop immediately unless you sign up for BostonGlobe.com digital subscription. Current print and digital subscribers are not eligible for the free trial.

Thanks & Welcome to Globe.com

You now have unlimited access for the next two weeks.

BostonGlobe.com complimentary digital access has been provided to you, without a subscription, for free starting today and ending in 14 days. After the free trial period, your free BostonGlobe.com digital access will stop immediately unless you sign up for BostonGlobe.com digital subscription. Current print and digital subscribers are not eligible for the free trial.