Gulbuddin Hekmatyar was born in 1947 in Imam Sahib District of the Kunduz province, northern Afghanistan, a member of the Kharoti tribe of the Ghilji Pashtun. His father, Ghulam Qader, who migrated to Kunduz, is originally from the center of Ghazni province. Afghan businessman and Kharoti tribal leader Gholam Serwar Nasher deemed Hekmatyar to be a bright young man and sent him to the Mahtab Qala military academy in 1968, but he was expelled due to his political views two years later. From 1970 to 1972, Hekmatyar attended Kabul University's engineering department.

The Pakistani military had supported Hekmatyar until then in the hope of installing a Pashtun-dominated government in Kabul, which would be friendly to their interests. By 1994, it had become clear that Hekmatyar would never achieve this, and that his extremism had antagonised most Pashtuns, so the Pakistanis began turning towards the predominantly Pashtun Taliban. After capturing Kandahar in November 1994, the Taliban made rapid progress towards Kabul, making inroads into Hezb-i Islami positions. They captured Wardak on 2 February 1995, and moved on to Maidan Shahr on 10 February and Mohammed Agha the next day. Very soon, Hekmatyar found himself caught between the advancing Taliban and the government forces, and the morale of his men collapsed. On 14 February, he was forced to abandon his headquarters at Charasiab, from where rockets were fired at Kabul, and flee in disorder to Surobi.  Nonetheless, in May 1996, Rabbani and Hekmatyar finally formed a power-sharing government in which Hekmatyar was made prime minister. Rabbani was anxious to enhance the legitimacy of his government by enlisting the support of Pashtun leaders. However, the Mahipar agreement did not bring any such benefits to him as Hekmatyar had little grassroots support, but did have many adverse effects: it caused outrage among Jamiat supporters, and among the population of Kabul, who had endured Hekmatyar's attacks for the last four years. Moreover, the agreement was clearly not what the Pakistanis wanted, and convinced them of Hekmatyar's weakness, and that they should shift their aid entirely over to the Taliban. Hekmatyar took office on 26 June, and immediately started issuing severe decrees on women's dress, that struck a sharp contrast with the relatively liberal policy that Massoud had followed until then. The Taliban responded to the agreement with a further spate of rocket attacks on the capital. The Rabbani/Hekmatyar regime lasted only a few months before the Taliban took control of Kabul in September 1996. Many of the HIG local commanders joined the Taliban "both out of ideological sympathy and for reason of tribal solidarity."  Those that did not were expelled by the Taliban. In Pakistan Hezb-e-Islami training camps "were taken over by the Taliban and handed over" to Jamiat Ulema-e-Islam (JUI) groups such as the Sipah-e-Sahaba Pakistan (SSP).  Hekmatyar then fled to Iran in 1997 where he is said to have resided for almost six years. Although himself claimed in August 1998 that he still remained in Afghanistan. Isolated from Afghanistan he is reported to have "lost ... his power base back home" to defections or inactivity of former members. He was also distrusted by the Iranian Government who found him too unpredictable, unreliable, and an unnecessary liability, considering its tense relations at the time with the Taliban and the Pakistani government, and despite his pleas, the Iranian Revolutionary Guards refused to establish a proxy through any of his organizations or assist him in any way. Allegedly, they even cut his phone lines and turned away anyone who wished to see him in his villa in North Tehran.

Using a quote from the above article, answer the following question: How did he get involved with the Taliban?
The Pakistani military had supported Hekmatyar until then in the hope of installing a Pashtun-dominated government in Kabul,