Iraq's parliament has elected Fouad Massoum as the country's new president, after weeks of wrangling between members of different Kurdish factions.
The five main Kurdish blocks picked the member of the Patriotic Union of Kurdistan (PUK), as its presidential candidate for the position of president during an internal voting session late on Wednesday night.
The PUK has initially put forward two candidates to run for the largely ceremonial office, Massuom won with 30 votes and his rival, Barham Salih, received 23 votes.
Massoum is a cofounder of PUK which is led by outgoing president, the ailing Jalal Talabani, and briefly served as the speaker of an interim legislature in 2004.
His rival Salih served in different capacities including Iraq's deputy prime minister.
The internal Kurdish vote came after Iraq's parliament failed to elect a new president on Wednesday as the Kurds who are expected to hold the office could not agree on one candidate.
Although there is no legal text that mandates the presidency should go to Kurds, it has become a tradition over the past eight years for Kurds to hold the presidential office, while the prime minister is a Shia and a Sunni Arab receives the post of parliament speaker.
Iraqi parliamentarians confirmed Massoum's presidency on Thursday. Kurdish politicians had been worried that their inability to select a candidate would have rendered them unable to secure the position.
RELATED: Iraq's Kurds push for independence referendum
In a press conference in the Kurdish capital, Erbil, a senior PUK official, Mala Bakhtiyar, said: "If Kurds do not hold the post of president, we will withdraw from the political process [in Iraq]."
According to Iraq's constitution, a candidate needs to gain two-thirds of the votes to hold the office of the country's president. Of the 269 parliamentarians present in Thursday's session, Massoum received backing from 175 in the first round of voting, falling short of the 180 votes needed. In the second round he won with a resounding 217 votes.
Kurdish groups had agreed PUK will nominate the Kurdish candidate for the position as it came second among Kurdish groups in the recent Iraqi parliamentary elections in April.
The other major Kurdish party, the Kurdistan Democratic Party (KDP) led by Massoud Barzani, holds the office of president and prime minister of the autonomous Kurdistan region.
But PUK's inability to pick a consensus candidate had sparked angry reactions in Kurdistan.
"The lack of a united stance regarding a presidential candidate will harm Kurdish interests," said Renas Jano, an Iraqi parliament member from the Kurdistan Democratic Party (KDP). "This is not only a matter that concerns a particular political party. This will be detrimental to us all."
When after nearly two years of medical treatment in Germany, Talabani returned home over the weekend to the city of Sulaymaniyah in the northern part of the country, the party he struggled hard for decades to keep united was in an awkward position.
RELATED: US to deploy more troops to Iraq
After weeks of animated discussions on who should replace Talabani as Iraq's next president, the leaders of the Patriotic Union of Kurdistan (PUK) could not agree on a single candidate.
Senior PUK official and governor of the oil-rich Kirkuk province Najmaldin Karim announced last week that he had submitted his name to the Iraqi parliament as a contender for the presidential office even though his party did not endorse the move.
But Karim pulled out of the race on the voting day in favor of Massoum. Some Iraqi groups such as Prime Minister Nuri al-Maliki's State of Law Coalition (SLC) have been trying to capitalise on the rifts within the Kurdish front.
"Other groups do see an opportunity to split Iraqi Kurdish political stance," said Ahmed Ali, senior Iraq analyst at the Washington-based Institute for the Study of War. "The current political dynamics do represent a challenge to the Iraqi Kurds vis-à-vis relations with Baghdad."
Kurds initially expected PUK's highest executive body, the politburo, to put things in order and officially nominate a candidate for the position.
But deep-seated internal rivalries within the PUK prevented the party from doing that.
IN PICTURES: Tension in Kirkuk
The body sent shockwaves across the Kurdish and Iraqi political spectrum when on July 20 it put forward two names as its choices for the position of Iraqi president.
Kurdish parties have around 60 seats in the 328-member Iraqi parliament and had agreed to allow the PUK to take the position of Iraq's president.
Although many initially expected PUK to nominate Barham Salih for the presidential office, as he has a higher profile nationally and internationally than Massoum, factional rivalries inside the party produced different results.
Hero Ibrahim Ahmed, Jalal Talabani's wife and one of the most powerful party figures, signalled her opposition to Salih's presidency in a statement last week.
"The post should go to someone who has been an example of fortitude and devotion to the party during different political phases," said Ahmed in a tacit rejection of Salih.
After PUK fared poorly in Iraqi Kurdistan's parliamentary elections late last year, Salih started distancing itself from the party's leadership.
He refused to play a notable role in PUK's Iraqi parliamentary election campaign held in April. But as PUK managed to regain part of its lost strength during the April elections, the fallout between him and Ahmed deepened.
In the absence of President Talabani, the decision making authority has been undermined... So the politburo had only one option to prevent the party from fracturing over this issue and had to come up with two nominees for the president's office.
PUK officials themselves openly admit the party suffers from an internal crisis.
"In the absence of President Talabani, the decision making authority has been undermined," said Sherko Manguri, a PUK member of Iraqi parliament. "So the politburo had only one option to prevent the party from fracturing over this issue and had to come up with two nominees for the president's office."
Noted for his manoeuvering and mediating skills, Talabani acted for decades as the uniting figure in the factionalised party.
Since Talabani left Iraq for a German hospital in December 2012, PUK has lurched from one crisis to another.
Besides the president who is expected to be a Kurd, two vice presidents, one Shia and one Sunni, will be also elected chosen in the coming days.
There were concerns among Kurds that if Mutlak insists on running, it might complicate things for the Kurdish nominee.
Salih Mutlak, a Sunni Arab politician, has reportedly decided to compete for the office.
When Iraqi lawmakers last week elected a speaker and his two deputies for the parliament, veteran Iraqi politician Ahmed Chalabi surprised many when he decided to run for the position of first deputy contrary to plans by Shia blocs to only have one nominee from Maliki's group.
Chalabi came close to the main Shia nominee Haidar al-Obadi forcing a second round of voting when he pulled out of the race.