'Man, they really hit on something with this Starbucks idea, didn't they?" says Jerry Seinfeld, sips on the first mocha latte of his life and glances around at the assortment of Upper West Siders clustered around the small tables. It may appear to them, as they glance up, disbelieving, from their steaming cups, that Seinfeld is simply hanging around, wasting time, much as Jerry and George might have done in an episode of his long-running, ridiculously popular sitcom. But he is not. He is working.

To promote the release in the US next month of Comedian, a surprisingly angst-filled documentary about Seinfeld's full-time return to the world of stand-up comedy, he has come up with a bizarre challenge for himself. For three hours, he and I will wander around his neighbourhood on the Upper West Side and talk about what we see and whether something in it might provide the seed for a good stand-up routine.

Then he will spend the rest of the afternoon writing a new comedy bit drawn from the day's wanderings. Finally, tonight, he will make a surprise appearance at a downtown comedy club, perform the new material and see how the audience responds. "This is really a crazy idea, you know," he says. "It probably won't work, but that will be interesting, too. You have to motivate yourself with challenges. That's how you know you're still alive. Once you start doing only what you've already proven you can do, you're on the road to death."

Shortly after new episodes of Seinfeld stopped running on NBC in 1998, Seinfeld announced that not only was he returning to stand-up, but that he was also going to retire all his old material and build a new act from scratch. He says he always felt that the best comics - Richard Pryor, George Carlin and, above all, Bill Cosby - were those who were capable of creating new acts with entirely new material on a regular basis. Seinfeld wanted to prove to himself that he could do that, too - that his name belonged alongside theirs.

"I'll tell you how this started," he says. "I was working Boston or someplace. Adam Sandler was opening for me. It was 1993 or so, and I started to do this bit and someone out in the audience went, 'Heard it!' It was like someone throwing a spear in the balcony and it went right through my chest. Because you're presenting your material like it's all fresh and new and clever, and here's this guy going, 'Heard it!' That was a moment of such intense pain. Just to avoid that ever happening again, I went through all of this." It is that process that is chronicled in Comedian.

The challenge begins on the kerb outside Zabar's, about 11.15am on a sunny July day. Seinfeld pulls up in a chauffeured sedan and bounds into the warm morning light. For nearly an hour, we walk south along Broadway, poking our noses into Citarella's gourmet shop ("Is it my imagination, or are desserts getting bigger and higher? Like they're wearing a Wonderbra") and the cheese counter at Fairway.

At this point he recalls how he recently, for the first time, followed the instructions on the back of the Quaker Oats box for the stove-top method after years of microwaving. It was a revelation, he says. I tell him I have my own method, involving three periods of microwaving with a short rest between each.

"I can't believe we are arguing about cereal," he says. "This is really a George and Jerry conversation. Please, will you do me a favour? It's just five minutes on the stove top. Try it. Just make it once. It's fluffy and it's not sticky."

Seinfeld pauses at a red light and takes a deep breath. "That's one of the biggest things I miss, those idiotic Jerry-George conversations," he says.

A lot of things seem to remind him of the television series. A poster for Mel Gibson's latest movie, Signs, showing a huge crop circle, reminds him that his character on the show once picked up a woman on an elevator by leaning over and saying in her ear, "You know, I was the one who did all those crop circles." Another restaurant along Columbus, Pomodoro, he points out, was the inspiration for the "break-up place", where everyone went to end their relationships.

By 1pm, we have wandered into the Starbucks to sit down. He is beginning to worry. A few funny ideas have occurred to him, but nothing strong enough to sustain a whole "bit". And time is running out. "Where do they get these names for their coffee drinks?" he asks, draining a little more of his mocha latte. Maybe he'll add a line about the funny Starbucks names, he says, although that will just be a one-liner, not a "bit".

"A bit is a real idea that has some insight," he says. "And then you develop that insight into a series of things. I won't do something unless I can get at least two or three good laughs out of it. If I can't, it's not gonna make the team."

He pulls out a sheet of yellow-lined paper and begins to scribble. "I'd better start putting something down," he says. He writes down the idea about Starbucks names. He notes the extremely low-riding trousers that a woman at the counter is wearing. "Here's what I think that is," he says. "It's a time-saving device. When you need to go to the bathroom, you are that much closer to having your pants off." But he rejects it as just a line, not a bit.

Seinfeld is 48 and has been married since 1999 to Jessica Sklar, with whom he has a daughter, Sascha, who will be two in November. And that, he says, has changed not only his outlook on life, but his approach to comedy. "I didn't know there was a laugh that was better than any laugh I had ever heard before," he says. "But there is. That one little girl laughing is better than 3,000 people."

A young couple is seated at a table near the window. They are clearly dating, a little awkward, trying to be cool. Seinfeld studies them. "I'll tell you one thing, since I'm married, single people look absolutely ridiculous to me," he says. "I held out for a long time. I wanted to keep it going. But now that I have passed through to the other side, I can see how stupid single people act."

He jots a few notes on the yellow sheet. "There might be something there, what do you think?" He scribbles some more. "Of course, when I was single, and I looked at married people, especially the ones with kids, I was horrified," he continues, warming to it. "Why would people do that to themselves?"

He begins to scribble more furiously. "I think this might work," he says. The way married people look at single people compared to the way single people look at married people who have kids. I think there might be something there."

9.30pm, Gotham Comedy Club, 34 West 22nd Street

"I didn't have much time," Seinfeld says apologetically as he walks through the door of this upmarket club in the Chelsea district, unfolding a yellow sheet covered with scribbles. "I only had about an hour to work on this. I'm going to have to practically read it, because I don't know it yet. You know, this whole idea is a little ridiculous. It's completely unrefined thought."

Inside the club, the announcer tells the audience that Jerry Seinfeld has dropped in. There are gasps, laughs of disbelief, and then Seinfeld steps through the black curtain and the room erupts. "I can't believe it, either!" he gasps back at the audience.

His plan is to warm up the audience with some tried and true material before launching into the new stuff, and it comes about 10 minutes into his act. "This is where the big comedians come to try out new jokes," he tells them, pulling the yellow sheet from his pocket. "So that's what I have here. I have some new jokes. We'll see what happens."

He was just in Starbucks that afternoon for the second time in his life, he says, and does the bit about the funny coffee names. It gets a laugh, but not a big one. "I'm married now and have a baby," he says, to a chorus of cheers. "Can you believe it? Me? But it was time, right? I used to be one of those single guys who I am sure are here tonight. I couldn't picture myself there, in that situation. When you are single and you see people with children, you can't believe it. You wonder, 'Who would go and do that to themselves?' "

This gets a solid laugh.

"Why would you willingly put yourself in that situation?" he continues. "Where you are standing in the middle of a grocery-store aisle with something that is hysterically screaming and holding a box of Pop Tarts?"

More laughs, but a little softer, more tentative. "Why would you want something in your life that stands in the middle of your living room, looks you in the eye and then poops in their pants? As they look at you! I tell you, it's a little unnerving."

A huge laugh now. He glances down at the paper, continuing. Now that he has moved through the "impenetrable wall" to married life, he says, he is astonished at how foolish single people act - especially when talking about their relationships.

"Oh, yes, we're having trouble in our relationship and we're trying to make it work," he says, shaking his head in mock disbelief. "OK. Here's the secret I'm going to tell you about relationships. Are you ready? They don't work. 'Oh no, Jerry,' you'll say. 'I just have to find the right person. I've got to find them.' "

The biggest laughs yet, so loud that he has to wait for them to diminish before continuing. "'Why can't I find them? If I could just find that person, then the relationship would work.' " He shakes his head. "I love my wife. I adore my wife. My wife is the greatest person I have ever met in my life. And she thinks I am the greatest person she has ever met in her life. And she believes it. And we say it to each other all the time. Do you know why?"

A few minutes later, Seinfeld is back out in the lobby, grinning happily. He accepts a few congratulations, and a small bottle of mineral water from the bartender. "I was kind of herky-jerky," he says. "But I could feel that the area has got some real juice in it. I'll rewrite it 20 more times now, but I think there's really something there."

He drains the last of the water. "Not bad for an hour's work," he says. "I'll take it."

He smiles broadly and begins for the door, then turns back. "You know, I want to reassure you that this was honest," he says. "I could have taken something and pretended. I could have used material that I'd come up with before. But I really did do this. I could easily have cheated, but I didn't."

His driver pulls up outside.

"I didn't think it would work," he says. "But I thought it would be just as interesting if it didn't. But it happened to work. Amazing. That was really fun."