It all started in the summer of 2010, when author Joe McGin­niss migrated from Massachusetts to Alaska, to be closer to nature. Human nature, at least, as it plays out on the Sarah Palin homestead.

The self-assigned Palin biographer, as you may recall, made headlines by renting a residence in Wasilla and moving in next door to Palin as if moving in on his prey. The former Alaska guv sounded ticked. McGinniss sounded tickled. And much of the public chose sides over all this northern overexposure.

And then there was a fictional twist that McGinniss never saw coming.

In this surreal world, a stranger — faux Fox News reporter Roland Hedley from the comic strip “Doonesbury” — moves in next to McGinniss. The snooping khaki-clad interloper sets up surveillance. Perhaps most unnerving, the stranger begins hectoring the author with back-porch taunts: “Moving next to Palin was seriously creepy,” he says. “How does it feel to be stalked, stalker?”

But the fictional character’s arrival in McGinniss’s real life marked the beginning of a beautiful relationship. This month, Doonesbury’s creator, Garry Trudeau, has partnered with McGinniss for a cartoon collaboration. (“A wild rumpus, as Joe put it,” Trudeau says.)

Check out the funnies Monday, and you’ll see Hedley reading excerpts from McGinniss’s bio, “The Rogue: Searching for the Real Sarah Palin,” ahead of its Sept. 20 release date.

“You know what she was?” says a member of Palin’s security detail in the excerpt Hedley reads. “A housewife who happened to be governor. I’d fly cross-country with her many times and she’d spend the whole trip looking at People magazine.”

From her preference for gossip tabs to her employment practices, from parenting to personal romance, these are among the sneak peeks into McGinniss’s Palin biography that Trudeau provides in the comic-strip tease.

Trudeau and Lee Salem, president of “Doonesbury” syndicate Universal Uclick, confirm that the excerpts are from the advance edition that the cartoonist received last spring, courtesy of the author. McGinniss did not return requests for comment, but his publicist at Random House/Crown said, “I can confirm that Joe did like the 2010 ‘Doonesbury’ cartoons, and [that’s] why his agent reached out to Mr. Trudeau.”

As for Trudeau, he says, “McGinniss’s office first approached me for [the 2010] strip-reprint rights in March, and then subsequently about a possible review.” The cartoonist says he “demurred on the review, but proposed instead an exclusive first serial arrangement.”

In “Doonesbury’s” current story arc, Hedley — through fortuitous contact with an author and a publisher’s mix-up — scores an early look at a hotly anticipated Palin biography. Intrigued by the book’s revelations, the media figure has a challenge: How to use this news to suit his chosen medium?

A scenario, in other words, not dissimilar from Trudeau’s.

“I did warn Joe, though, that the deal required the cooperation of my imagination,” Trudeau says of the partnership.

In culling the 300-plus-page book for content, Trudeau says there was “an embarrassment of riches. . . . And, of course, there were revelations that didn’t make the cut because I couldn’t figure out how to make them work as comedy.”

When he finished the book, though, the cartoonist said he wasn’t sure he had “a way in.”

That “way in” turned out to be through Twitter, as a character bearing a striking similarity to Fox News boss Roger Ailes orders Hedley to do damage control by issuing “fair and balanced,” positive-spin tweets about the book. As the fictional Ailes points out, “Sarah’s a major asset for Fox!” (Representatives for Palin and Ailes did not return calls or e-mails seeking comment.)

McGinniss, in turn, has been blogging about “Doonesbury’s” “Rogue” strips. On Saturday, the author wrote on his blog that the goal was to “distract you from important issues by making you wonder what’ll happen next.”

Any heat from this serial deal, of course, can benefit Trudeau and McGinniss — born in the ’40s, both won early acclaim for writing about President Richard M. Nixon: McGinnis for “The Selling of the President” and Trudeau for his Pulitzer-winning Watergate strips.

The Palin satire, says Universal Uclick president Salem, is “certainly within the tradition of the strip.”

Trudeau says he has no interest in seeing Palin stick around the national scene as a potential candidate.

“I’d say her strategy flows from an unusually deep need to get the most attention for the longest period of time,” the comic political commentator says. “For 2011, that means stringing out her decision whether to run. For 2012, it’ll mean stringing out her endorsement of [Texas Governor Rick] Perry. . . .

“Professional interests aside, I would not like to see her enter the race.”

Yet as a regular target of “Doonesbury” leftist satire since 2008, Trudeau acknowledges, “she’s up there with go-tos Quayle, Dubya and Trump.”