BAGHDAD — Prime Minister Nouri al-Maliki edged ahead Sunday in a tight race in the country’s parliamentary elections after partial results from all of Iraq’s 18 provinces showed his bloc leading in seven — two more than his chief rival.

The early tally strengthens al-Maliki’s chances of retaining the prime minister’s post, although he is unlikely to win a majority necessary to govern alone. Instead, the narrow race could lead to months of political wrangling as leaders try to cobble together a coalition government that will rule as American forces leave Iraq in 2011.

The March 7 vote was Iraq’s second for a full-term government since the U.S.-led invasion in 2003.

According to the partial count from all of Iraq’s 18 provinces released by the country’s electoral commission, al-Maliki’s State of Law coalition leads in seven provinces.

His closest challenger, the secular Iraqiya bloc led former Prime Minister Ayad Allawi, leads in five provinces, while the religious Shiite Iraqi National Alliance and the main Kurdish coalition each lead in three.

The results were based on partial vote counts released over the past three days, with the percentage of polling stations counted in each province ranging from 10 to 67 percent.

In his first public appearance since minor surgery Wednesday, a confident looking al-Maliki praised Iraqis Sunday for defying those who used violence to try to keep them from the polls, saying “the Iraqi people can not be intimidated.”

Insurgent attacks had killed 36 people on election day.

On Sunday, partial results came in for the remaining seven provinces that had yet reported results.

Al-Maliki’s coalition was ahead in the key, oil-rich province of Basra — home to Iraq’s second largest city and the center of the country’s oil industry. With about 63 percent of the Basra votes counted, al-Maliki’s group appeared a definitive winner, nearly 100,000 votes ahead of his closest competitor, the INA.