"Stranger Than Fiction" is a poetic and thoughtful rummage through the cosmic closet with a comic actor best known for less intelligent fare. Now that's stranger than fiction.

And while the result ain't exactly rocket science, it is engaging and ambitious in ways that Hollywood films usually aren't.

Will Ferrell is the latest commercially successful comedian to seek validation, if not rehabilitation, through more serious material and, in doing so, expose the relationship between comedy and tragedy.

The character he plays, Harold Crick, is a by-the-numbers IRS agent who counts stair steps and toothbrush strokes. He lives a linear, literal and solitary life. (He was once engaged to an auditor, but she left him for an actuary.)

So when he is confronted with an existential crisis, his brain does not actually explode, he just never sees his world or anything in it the same way again.

Self-awareness is usually a good thing, but for Harold, it comes with the discovery that he is not real.

One day, he hears a voice in his head narrating the futility of his mind-numbing routine and his fate as being predestined, much as an author would describe a series of events for a reader. And as he seeks to understand what is going on, he slowly discovers that he is the fictional invention of a writer, played by Emma Thompson.

The bad news is that she does not know he is alive and has plans to kill him in her new book.

The good news is that she has writer's block. So he has as long as it lasts to figure out how to forestall his demise, with help from a college professor played by Dustin Hoffman.

During this process, Harold transforms himself from a gray bureaucratic drone into a normal guy interested in the world and, particularly, one person in it - a Bohemian baker played by Maggie Gyllenhaal, whom he has been sent to audit.

When one of her cookies sends him into a Proustian swoon, it, she and the realization of all that he has missed give him a renewed sense of purpose and, needless to say, a reason to live.

Director Marc Forster, whose "Finding Neverland" was a more formal exercise in imagination and fantasy mechanics, is working at a metaphysical level here, from a debut screenplay by Zach Helm.

The "Groundhog Day"-type scenario is arbitrarily ruled by Thompson's distracted and detached omniscience, as she is dressed in pajamas and chain-smoking while overlooking all that she has created. (Her only contact is with an editor's assistant played by Queen Latifah, whose character is a superfluous dramatic device and the film's solitary false note.)

If Harold's relationship with the tattooed Gyllenhaal is the emotional centerpiece of "Stranger Than Fiction," Hoffman's delightful, caffeine-addled academic represents its alternative consciousness lurking like a troll beneath the bridge between art and the art of life.

Comparisons with other films are legion, and two of them starred Jim Carrey: "Eternal Sunshine of the Spotless Mind," in which a man battles the windmills of his mind, and "The Truman Show," in which a man finds he is a character on a reality TV show.

But even a subdued Carrey calls attention to himself. Here, an understated Ferrell is, for the moment, content to let Sacha Baron Cohen's character of Borat drag a high concept through shallow and muddy waters.

Who knows? After having taken the high ground for once, Ferrell may find that, like the metamorphosed Harold Crick, he likes the change in perspective.