As president of Iraq from 2005 to 2014, Jalal Talabani, who has died aged 83, was the first non-Arab to lead the nation in modern times. He was a prominent figure in Kurdish politics, and his election as head of state marked a milestone for a people whose rights had been neglected for centuries. Kurds, numbering more than 30 million, do not have a state of their own, but live as minorities predominantly in Turkey, Iran, Iraq and Syria. A former Kurdish separatist fighter involved in resistance against the Iraqi government from the 1960s, Talabani rose to the top through a mixture of determination, guile and good luck.

For many years he infuriated Sunni Arab-dominated Baghdad. Ankara, too, feared that he would lure Turkish Kurds into a belligerent, breakaway republic. Many Iraqi Kurds regretted his fierce turf wars with the Barzani clan. After Saddam Hussein unleashed genocidal attacks on Iraqi Kurds in 1988 and 1991, Talabani’s demise seemed inevitable.

Then, in 1992, he established a functioning regime in Sulaymaniyah province. By 2003, his 31,000 Peshmerga resistance fighters were able to repel Iraqi soldiers with only minimal US assistance. His fiefdom seemed an oasis of stability in the turmoil that followed Saddam’s fall that year, and Talabani was chosen as a member of the interim Iraq governing council.

In 2005 he contested national elections in coalition with his former rival, Masoud Barzani. They won 75 out of 275 seats, coming a respectable second to the winning Shia Arab list. Later that year, religious Shias, Turkmens in the disputed oil-rich city of Kirkuk and even some Sunnis backed the Kurdish secularist to be president. Syrian, Turkish and Iranian Kurds were jubilant.

Talabani cut a paradoxical figure: part devotee of good food and fine cigars, part mountain warrior. He instituted a ministry of human rights in the Kurdish northern province of Iraq, yet was prone to autocratic outbursts. He nurtured ties with both the CIA and the Iranian Revolutionary Guards. At his presidential inauguration, he condemned Saddam’s “hideous fascistic dictatorship”, even though he had been shown on television kissing the dictator in 1991 during one of their periodic rapprochements.

In 2006 he was re-elected under a new constitution, with Sunni and Shia vice-presidents, and transformed what had been a primarily ceremonial role into a more active one, whether as a defender of the constitution, or as commander of the Iraqi special operations forces.

He married Hero Ibrahim Ahmed in 1970. A former guerrilla, and daughter of Ibrahim Ahmed, a Kurdish Marxist, she partnered him in his political endeavours, promoted women’s rights, sponsored artists, founded Kurdistan Save the Children and helped run the KurdSat TV channel.

Born in Kelkan, near Lake Dokan, at 14 Talabani joined the Kurdish Democratic party (KDP), newly created by Mustafa Barzani, Masoud’s father. A member of the KDP central committee at 18, Talabani began studying law at Baghdad University two years later, in 1953. He was forced into hiding in 1956 as a result of the prime minister Nuri Said’s clampdown on rising student protests. Then in 1958 General Abd al-Karim Qasim overthrew the monarchy, declared Iraq equally Arab and Kurdish, and legalised the KDP.

Allowed to graduate in 1959, Talabani briefly commanded an Iraqi tank unit. That year Mustafa Barzani promoted Talabani and Ahmed, his future father-in-law, to the KDP politburo as threats mounted from Kurdish communists. Repression returned, however, and prompted another uprising in 1961. Talabani took charge of Peshmerga battalions around Sulaymaniyah and Kirkuk and routed government forces. Abdul Salam Arif ousted Qasim in 1963, and opened talks with Talabani, but conflict rumbled on.

Young, urban and sophisticated, fluent in Arabic, Persian, French and English, Talabani increasingly saw Mustafa Barzani as an antiquated tribalist. They also drew on different constituencies.

Talabani and Ahmed’s progressive clique fought against the KDP mainstream. In 1964 they were expelled to Iran, but returned to the fold when Mustafa Barzani negotiated self-rule terms with Baghdad’s new Ba’athist rulers in 1970. Talabani became KDP envoy to Syria, Libya and Europe, and met the US president, Richard Nixon, and his secretary of state, Henry Kissinger, in Washington.

However, Kurds revolted in 1974 after Baghdad broke promises to grant them jurisdiction over Kirkuk. When Iran and the US ceased arming the rebels in March 1975, Talabani fled to the Syrian capital of Damascus, and met members of the Popular Front for the Liberation of Palestine, in neighbouring Lebanon.

Impressed by the PFLP’s zealotry, he founded the Leninist Patriotic Union of Kurdistan (PUK) to rival the KDP that June, and launched hostilities in Iraq the following year. In 1979 Saddam assumed absolute power in Iraq and in 1980 launched the invasion of Iran that started an eight-year war.

After Mustafa Barzani’s death in 1979, he was succeeded by Masoud, who sided with the new Islamic regime in Tehran. Talabani’s initially more patriotic stance dissolved as Baghdad troops attacked his Peshmerga. Agents killed his brother and two nieces in 1985, the PUK openly sided with Tehran, and in 1987 the PUK and KDP united in an Iranian-backed Kurdistan Front.

Saddam retaliated in 1988 with a violent attack on PUK areas. According to Kurdish officials, around 4,500 villages were flattened, and overall an estimated 182,000 Kurds died.

Talabani returned from Syria in 1991 after the US encouraged the overthrow of the Iraqi regime. But when the US failed to help the rebels, Saddam counter-attacked. Some 1.5 million Kurds fled to the mountains. Fearing a humanitarian disaster, the UN imposed a safe haven in northern Iraq, under cover of an Anglo-American no-fly zone. Talabani negotiated a ceasefire that saved thousands of lives. The PUK and KDP fought elections in 1992 and gained 50 seats each, with a slight edge to Barzani’s faction. Their joint Kurdish Regional Government (KRG) quickly split into distinct administrations. Internecine fighting erupted in 1994 until the US brokered a truce in 1998.

Under the Kurdish prime minister Barham Salih, the PUK zone revived farmland and built schools. Notwithstanding charges of corruption and smuggling, Talabani invested oil-for-food revenues, protected his Chaldean and Assyrian Christian minority subjects and revived Kurdish language instruction.

He largely eschewed Iraqi expatriate politics, preferring “the opposition of the trenches to the opposition of the hotels”. At home he denied sanctuary to the Turkish Kurdish rebels of the PKK and harried al-Qaida-affiliated Kurdish groups. Despite denials, he apparently maintained ties with Israel; many Iraqis were angered when he shook the hand of the Israeli prime minister Ehud Barak at a Socialist International meeting in 2008.

After the US invasion of 2003, Talabani played a key role in fashioning Iraq’s new interim constitution. In 2005 he effectively bequeathed the KRG to Masoud Barzani. He persuaded Iraq’s Kurds to embrace the notion of economic, cultural and military autarchy within a federalised republic. He offered an olive branch to Sunnis, who had boycotted elections, rejected Islamic rule and controversially asked American troops to stay. Talabani even suspended his dream of making Kirkuk capital of an independent Kurdistan.

As the first permanent president of a post-Saddam Iraq, Talabani somehow held sway over a nation still racked by violence and hosted the first Arab League summit in Baghdad in 20 years. Acts of terror occurred mostly outside the Kurdish zone. Yet even there the PUK-KDP old guard were accused of corruption and of repressing Nawshirwan Mustafa’s rising opposition Movement for Change during regional elections in 2009.

On a visit to the Cambridge Union in 2007, Talabani praised Tony Blair as a “hero” for securing Iraq’s freedom. Interviewed by al-Jazeera in early 2012, Talabani said he welcomed a democracy where people could publicly attack even the head of state. He maintained that Kurdistani independence was “not possible” and that Kurdish interests were best served within a federated Iraq. It needed a “brotherhood of Arabs and Kurds to fight dictatorships … [and] we must be realistic. This century is not the era of small countries [but] of big unions.”

A stroke incapacitated him in 2012 and he received medical treatment in Germany for the remainder of his time in office. In 2014 his fellow Kurd and PUK confidant, Fuad Masum, replaced him as president. By then Barzani had strengthened his position in the Kurdish region through the key role that Kurdish forces took in the alliance repelling Isis from Iraq, and through the advisory independence referendum for Iraqi Kurdistan held last month. A spokesman for Barzani regretted that Talabani’s “wisdom and excellent co-operation” would no longer be available in the aftermath of the vote.

Talabani is survived by Hero and his sons Qubad, the KRG’s deputy prime minister since 2005, and Bafel .

• Jalal Talabani, politician, born 12 November 1933; died 3 October 2017