TEHRAN, Iran — Iraqi Prime Minister Nouri al-Maliki made his first official visit to Iran, a close ally, asking the Islamic regime on Tuesday to crack down on al-Qaida militants infiltrating his country and seeking new deals to help Iraq's troubled oil industry.

The visit reflected the complex relationship between Iran, a mostly Shiite Muslim country, and Iraq's government, now dominated in the post-Saddam Hussein era by Shiite allies of Tehran. Since Saddam's fall in 2003, Iraq has sought better relations with Iran and to heal scars left by the 1980-88 war that killed more than 1 million people on both sides.

The two enjoy increasingly strong ties that include new oil cooperation. Iraq has already turned to Iran for help with a chronic shortage of petroleum goods, reaching a deal last month to import Iranian gasoline, kerosene and cooking fuel. Iraqi officials said al-Maliki's visit and other recent exchanges could improve the cooperation.

But at the same time, the United States — the Iraqi government's other top ally and a bitter enemy of Iran — has repeatedly accused Tehran of interfering in Iraqi politics and allowing insurgents to cross the porous 1,000-mile border. Iran denies the claims.

Moreover, Iraq is struggling to control months of brutal Shiite-Sunni sectarian violence, some of which is blamed on Shiite militias that are linked to parties in the government but also believed to have ties with Iran.

Al-Maliki's welcome was warm in Iran, where he spent part of his yearslong exile from Iraq during Saddam's rule.

The Iraqi premier had a red-carpet reception at the office of Iranian President Mahmoud Ahmadinejad. After their meeting, the two leaders exchanged jokes and answered questions from reporters.

"All our assistance to the Iraqi people will be to establish complete security" in Iraq, Ahmadinejad told a joint press conference, according to the state-run news agency.

"Iran and Iraq enjoy historical relations. These relations go beyond neighborly ties. Our relations will remain excellent," he said.

Al-Maliki said his visit would be "a turning point in the expansion of relations between Iran and Iraq that enjoy historical and ancient ties."

Asked about allegations that Iran was interfering in Iraq, al-Maliki said, "There is no obstacle in the way of implementing agreements between Iran and Iraq."

Neither mentioned the issue of al-Qaida militants. But Haidar al-Obadi, a parliament member from al-Maliki's Dawa Party, said the Iraqi leader was asking Iran "for cooperation in controlling the border to prevent any al-Qaida exploitation of the border."

"There are al-Qaida members and al-Qaida strongholds in Iran," he told the Associated Press in Cairo, speaking in a telephone interview from Baghdad. The militants have been "taking advantage of the long border" to smuggle weapons and people into Iraq "most likely without the Iranian government's knowledge," he said.

The United States accuses Tehran of harboring al-Qaida fugitives. Tehran has denied the charges and says it has no interest in fomenting instability across the border. However, Iran has not ruled out the possibility that some infiltrators might have crossed its border illegally. Al-Qaida's branch in Iraq has carried out some of the most brutal suicide attacks against Iraqi Shiites.

"We consider Iraq's progress, independence and territorial integrity as our own," Ahmadinejad said.

Ahmadinejad also said Iran hoped "unwanted guests will leave the region," a reference to U.S. forces in Iraq.

An Iraqi economic delegation visited Iran just before al-Maliki to discuss more petroleum deals, apparently further Iranian exports of gasoline and other fuel goods, said Haidar al-Obadi, another Dawa party parliamentarian.

Details of any new agreements have not been released. Al-Maliki said "Iraq is willing to expand its relations with Iran in the area of political and economic arenas especially energy and water."

Despite its huge oil reserves, Iraq has been suffering under shortages of fuel products because of the damage to the industry from insurgent attacks and the turmoil in the country. It has also turned to Syria and other countries for supplies.

In July 2005, former Iraqi Prime Minister Ibrahim al-Jaafari made a landmark visit to Iran, the first by an Iraqi premier since the 2003 U.S.-led invasion that toppled Saddam.

Since the fall of Saddam in 2003, the two countries have sought to heal scars left by the 1980-88 war that killed more than 1 million people on both sides.


Contributing: Qassem Abdul-Zahra