ISLAMABAD, Pakistan — President Gen. Pervez Musharraf freed thousands of opponents from jails Tuesday in a sign he is rolling back a wave of repression under emergency rule and flew to Saudi Arabia to talk about the future of an exiled rival, Nawaz Sharif.

Saudi officials said there were efforts to arrange a meeting between Musharraf and Sharif, who was ousted as prime minister by the general's 1999 coup. However, a Pakistani official said Musharraf's goal was to prevent Sharif from returning before parliamentary elections Jan. 8.

Back home, the political cauldron continued to boil, with dozens of journalists detained for several hours after clashing with police during a protest and newly freed opposition lawyers vowing to keep up their agitation.

But there was also some relief for Musharraf. Ex-premier Benazir Bhutto, leader of a key opposition party, deferred a decision on whether to boycott the elections, which the West hopes will produce a moderate government able to stand up to Pakistan's rising Islamic extremism.

The Interior Ministry said 3,400 people had been released from jail, among them political activists and lawyers at the forefront of protests against Musharraf before and after he decreed emergency rule Nov. 3, purging the Supreme Court and taking independent TV news off the air.

Ministry spokesman Javed Iqbal Cheema said more than 2,000 others remained behind bars but would be released shortly. "The process has started. More are being released today," he said.

Many high-ranking party activists and leaders, such as former cricket star-turned-politician Imran Khan and Aitzaz Ahsan, president of the Supreme Court Bar Association, remained in prison. Khan began a hunger strike Monday to protest emergency rule.

The government did not say what prompted the mass release. But it came two days after a visit by Deputy Secretary of State John Negroponte, who issued a blunt call for Musharraf to end emergency rule.

Washington and others worry the crackdown, and the political turmoil, will raise questions about the credibility of the parliamentary elections. Musharraf critics say the vote can't be free and fair because emergency rule restrictions will prevent his foes from campaigning effectively.

The Pakistani leader flew to Saudi Arabia on Tuesday on his first foreign trip since the crisis began.

While Washington remains Musharraf's key backer, providing billions of dollars in aid in return for Pakistan's help against al-Qaida and the Taliban, Saudi Arabia's own aid and investment give it considerable influence.

Saudis, including some among the royal family, have for years financed fundamentalist Sunni Muslim clerics and schools, giving the kingdom sway among Pakistan's powerful Islamic movements.

Musharraf talked with Saudi security officials for several hours before meeting with King Abdullah, Saudi authorities said, without giving any details of the discussions.

An official in Musharraf's office in Islamabad said Saudi leaders wanted the general to let Sharif return home and compete in the elections. Musharraf argued that Sharif, a leader in Pakistan's other main opposition party, could not come back now because that would worsen the unrest and threaten the country's stability, the official said.

The official said Musharraf had privately told aides that he would be prepared to let Sharif return after the vote, provided he toned down his rhetoric against the general.

A Saudi official said Musharraf had sought a meeting with Abdullah for a week. "He is counting on Saudi Arabia's historic ties (with Pakistan) to help him out of this crisis," the official said.

Both the Saudi and Pakistani officials agreed to discuss Musharraf's trip only if they were not quoted by name because they were not authorized to talk with journalists.

Pakistani state media said Musharraf would travel Wednesday to the Red Sea town of Jiddah, where Sharif lives, on route to perform a pilgrimage to Mecca.

The Saudi official said Musharraf had sought to meet with Sharif as a conciliatory gesture, another official said late Tuesday that efforts were continuing to arrange a meeting.

But both the Musharraf aide and officials in Sharif's party said no meeting had been arranged.

Sharif's party kept up its stiff criticism of Musharraf, insisting he would have to agree to give up power before they would talk to him. Sharif "does not believe in talking to a dictatorial regime," said the party's general secretary, Iqbal Jhagra.

Bhutto, who has been edging toward forming an opposition alliance with Sharif, said Sharif did not mention meeting with Musharraf when she spoke to Sharif on Monday.

Pulling back from her attacks of the past week, she avoided criticizing the Pakistani leader directly. She said it would be a "good sign" if Musharraf quit his second post as the powerful army chief as he has promised and ruled as a civilian president. She also said her party needed a few more days to decide whether to boycott the elections as Sharif as urged.

As part of the international pressure to defuse the crisis, Negroponte had appealed to both Musharraf and Bhutto to avoid "brinkmanship" in the political confrontation.

Having promised last week to quit his military post by month's end, Musharraf is expected to resign from the army quickly after the Supreme Court confirms his disputed presidential re-election by legislators. That ruling is expected Thursday from the court, which he stacked with loyal judges after imposing emergency rule.

Still, Musharraf has refused to set a date for lifting the state of emergency, suggesting it will continue through the election. He insists the crackdown was needed to stop judges from interfering with the government's fight against militants linked to the Taliban and al-Qaida.

"I take decisions in Pakistan's interest and I don't take ultimatums from anyone," Musharraf said in an interview with The Associated Press last week.

Associated Press writers Munir Ahmad, Sadaqat Jan and Stephen Graham in Islamabad, Zarar Khan in Karachi, Abdullah Shihri in Riyadh, Saudi Arabia, and Salah Nasrawi in Cairo, Egypt, contributed to this report.