NEW YORK (Fortune) -
"I thought I was replacing The Donald. It was even discussed that I would be firing The Donald on the first show," confesses Martha Stewart in Fortune, talking about her Apprentice and her small-screen counterpart, Donald Trump.

Stewart admits that when reality TV guru Mark Burnett first approached her in May of 2004, pitching her on The Apprentice, she was wary. She wanted to do a show called "The Entrepreneur." But Burnett persuaded her by telling her that she would replace Trump: "There wouldn't be another Apprentice," Stewart says. As it turned out, in January, while she was in prison, Trump re-upped to star in his Apprentice another season. In fact, he never knew about Stewart's plans to bump him from his show. "I wouldn't have allowed it!" he blows when Fortune informs him.

Today, neither Martha nor "The Donald," as she calls him, are happy that they are siphoning each other's viewers—thus depressing the ratings of both Apprentice shows. But you will not catch Stewart carping about the benefit of her star turn on TV. "We're getting six to seven million viewers a night," she says. "Guess what? That's damn good. People walk away from the show thinking, 'What a nice company that is,' and 'Boy, do they do good things.'" Indeed, Martha's Apprentice is a tremendous promotional platform, more valuable than millions in ad dollars could buy.

Love her or loathe her, it's hard not to be amazed by Stewart's dramatic reversal of fortune. A year ago she was incarcerated at Alderson Federal Prison Camp in the hills of West Virginia, for lying to government investigators about a suspicious stock trade. "I was in the wrong place at the wrong time. I fell in a hole," Stewart says in her first wide-ranging interview about her legal travails, her prison stay, and her comeback plan.

Today, at 64, she is ubiquitous. Her flagship magazine, Martha Stewart Living, has seen ad pages jump 48 percent; her new advice book, "The Martha Rules," is on the New York Times bestseller list. She's landed a syndicated daytime TV show, a $30 million satellite radio deal with Sirius, a DVD deal with Warner Home Video, a music deal with Sony BMG, even a partnership with KB Home to build Martha Stewart–branded residential communities. Revenues at Martha Stewart Living Omnimedia (Research) are rebounding after three years of declines. And after the company's seven consecutive quarters of losses, Wall Street projects a return to profitability next year.

Stewart, who is America's first self-made female billionaire, ranks No. 21 on Fortune's 2005 Most Powerful Women list. She got to that spot the hard way. But make no mistake: Serious risks persist. A Securities and Exchange Commission insider trading investigation is pending. Her company's stock, which doubled during her prison stay, is down 47 percent since her release in March, reducing the value of her personal holdings from $1 billion to just over $500 million.

One question investors are asking: Will Stewart, who sells $1 billion worth of merchandise annually at Kmart, expand her distribution to Sears, Kmart's new owner? Negotiations with Eddie Lampert, the hedge-fund owner who controls Kmart and Sears, have been difficult. "We have a plan that doesn't include Martha Stewart in Sears," he says. Stewart is "chomping at the bit" to get into Sears, she says. "Will it work out? I don't know yet."

No doubt, she will continue to drive her comeback the only way she knows how: full speed ahead. She even holds out the possibility that she could return to the chairman post of her company someday. "I have learned," Stewart says, "that I really cannot be destroyed."

The full story on Martha's comeback appears on fortune.com and will be on newsstands November 7.