TRIPOLI, Libya — After six months battling a rebellion that his family portrayed as an Islamist conspiracy, Col. Muammar el-Qaddafi’s son and one-time heir apparent said Wednesday that he was reversing course to forge a behind-the-scenes alliance with radical Islamist elements among the Libyan rebels to drive out their more liberal-minded confederates.

“The liberals will escape or be killed,” the son, Seif al-Islam el-Qaddafi, vowed in an hourlong interview that stretched past midnight. “We will do it together,” he added, wearing a newly grown beard and fingering Islamic prayer beads as he reclined on a love seat in a spare office tucked in a nearly deserted downtown hotel. “Libya will look like Saudi Arabia, like Iran. So what?”

The leading Islamist whom Mr. Qaddafi identified as his main counterpart in the talks, Ali Sallabi, acknowledged their conversations but dismissed any suggestion of an alliance. He said the Libyan Islamists supported the rebel leaders’ calls for a pluralistic democracy without the Qaddafis.

But the interview nonetheless offered a rare glimpse into the defiant, some say delusional, mentality of the Qaddafi family at a time when they have all but completely retreated from public view under the threat of a NATO bombing campaign, now five months old, and a six-month rebellion.

On one level, Mr. Qaddafi’s avowed embrace of the Islamists represents a sharp personal reversal for a man who had long styled himself as a cosmopolitan, Anglophile advocate of Western-style liberal democracy. He continues to refer to the Islamists as “terrorists” and “bloody men,” and says, “We don’t trust them, but we have to deal with them.”

But it may also be simply a twist on an old theme, a new version of the Qaddafi argument that by assisting the rebels the Western intervention could usher in a radical Islamist takeover. In a further taunt to the West, he suggested that the Qaddafis would even help the Islamists stamp out the liberals.

“You want us to make a compromise. O.K. You want us to share the pot. O.K., But with who?” he said in imagined dialogue with the Western powers. The Islamists, he said, answering his own questions, “are the real force on the ground.”

“Everybody is taking off the mask, and now you have to face the reality,” he said. “I know they are terrorists. They are bloody. They are not nice. But you have to accept them.” He seemed to enjoy repeating the notion that Western capitals would be forced to welcome the ambassadors or defense minister of a new Islamist Libya.

“It is a funny story,” he said, though he insisted in all seriousness that he and the Islamists would announce a joint communiqué within days, from both Tripoli and the rebels’ provisional capital of Benghazi, Libya. “We will have peace during Ramadan,” he said, referring to the current Islamic holy month.

Less than a week after the mysterious killing of the rebels’ top military commander, Gen. Abdul Fattah Younes, by rebel gunmen, Mr. Qaddafi also seemed to be trying to capitalize on potential divisions within their ranks. There have been suggestions that the general was killed by an Islamist faction, perhaps in retaliation for his actions in his former role as Colonel Qaddafi’s interior minister, charged with the detention and torture of radical Islamists.

“They decided to get rid of those people — the ex-military people like Abdul Fattah and the liberals — to take control of the whole operation,” Mr. Qaddafi said. “In other words, to take off the mask.”

He said that the rebel-held eastern city of Darna, long known as a hotbed of Islamist activism, had already come to resemble the lawless regions of Pakistan. “It is Waziristan on the Mediterranean,” he said, adding that he had reached an agreement with local Islamists to allow them to make it “an Islamic zone, like Mecca.”

An error has occurred. Please try again later.

You are already subscribed to this email.

His comments also conveyed a new disdain for peace talks — with either the rebels’ governing council or its NATO backers — which Qaddafi spokesmen still call for almost every day. Mr. Qaddafi attributed recognition by the United States and other countries of the rebels’ governing council to “a lot of idiot people around the world.” As for the rebels themselves, Mr. Qaddafi called them “rats” and their council “a fake,” “a joke” and “a puppet.”

Rebel leaders and Western governments have long acknowledged the presence of Islamists among the rebel fighters, including at least one who was previously imprisoned at Guantánamo Bay, Cuba, and another believed to have been in Afghanistan when Al Qaeda ran training camps under Taliban rule. But Western governments have so far accepted the Libyan Islamists’ pledges of support for a pluralistic democracy after the ouster of Colonel Qaddafi, concluding that their agenda is purely domestic and poses no broader threat.

Mr. Qaddafi, however, has his own history with Libya’s Islamists, many of whom his father sent to jail during a long campaign to stamp out an organization known as the Libyan Islamic Fighting Group. Under the umbrella of liberalization, the younger Mr. Qaddafi led an initiative to rehabilitate many of them.

“I released them from prison, I know them personally, they are my friends,” he said, though he added that he considered their release “of course a mistake,” because of their role in the revolt.

As for the future of an Islamist Libya, Mr. Qaddafi was vague on the details. He said that he had assented to Islamist demands to prohibit any constitution other than the Koran, though Mr. Sallabi, the Islamist leader, said he has written publicly in support of a civil constitution.

And Mr. Qaddafi refused to discuss his own or his father’s future role. That was a question for after negotiating a peace, he said. “It is like you shoot first and ask questions later.”

Although in recent weeks the rebellion has edged forward on three different fronts around Tripoli, Mr. Qaddafi insisted: “We are more united, relaxed, more confident. The rebels are losing every day.”

Mr. Qaddafi also described some of his family’s contacts with rebel officials that have stirred controversy. Many in the rebel ranks have suspected General Younes, a former Qaddafi confidant, of maintaining ties to his former boss, and the younger Mr. Qaddafi appeared to confirm those suspicions.

“We met him twice in Italy,” he said. “We told him, ‘You will be killed at the end of the day because you are playing with the snakes,’ and he said, ‘Nonsense.’ ”

But he talked mostly about his conversations with Mr. Sallabi, who Mr. Qaddafi called the “the real leader” of the rebellion and “the spiritual leader” of its Islamists. “He said liberals, the secular people, they are drunk all the time, they have no place here in Libya,” Mr. Qaddafi said. “These are our common enemies, those nice people with jackets and ties, flying in on private jets from Paris and London.”

But Mr. Sallabi said he welcomed the secular leaders. “Liberals are a part of Libya,” he said. “I believe in their right to present their political project and convince the people with it.” As for their conversations, Mr. Sallabi said that Mr. Qaddafi was the one who contacted the rebels. “There were many discussions between him and the opposition,” Mr. Sallabi said. “The first thing discussed is their departure from power.”

A version of this article appears in print on August 4, 2011, on Page A4 of the New York edition with the headline: Qaddafi Son Says Libya, in Shift, May Ally With Radical Islamist Rebels. Order Reprints|Today's Paper|Subscribe