The former Pakistani president Pervez Musharraf has ended more than four years in self-exile by flying to his homeland, seeking a possible political comeback in defiance of judicial investigations and death threats from Taliban militants.

Security forces whisked away Musharraf in a convoy of about a dozen vehicles shortly after he touched down in the southern port city of Karachi and did not allow him to greet hundreds of supporters waiting at the airport, ready to shower him with rose petals.

It is unclear if the security forces had detained Musharraf, who faces legal charges, or acted out of concern for his safety. Paramilitary rangers and police had been stationed at the airport awaiting his arrival.

The journey from exile in Dubai is intended as the first step in Musharraf's goal of rebuilding his image after years on the political margins. Since the former general was forced from power, Pakistan's civilian leadership has struggled with a sinking economy, resilient Islamic extremist factions and tensions with Washington over drone strikes and the secret raid that killed Osama bin Laden.

Musharraf represents a polarising force that could further complicate Pakistan's attempt to hold parliamentary elections in May and stage its first transition from one civilian government to another.

He is viewed as an enemy by many Islamic militants and others for his decision to side with the US in the response to the September 11 terrorist attacks. On Saturday, the Pakistani Taliban vowed to mobilise death squads to send Musharraf "to hell" if he returned.

Musharraf's supporters, including elements of the military and members of Pakistan's influential expatriate communities, consider him a strong leader whose voice – even if only in parliament – could help stabilise the country.

Musharraf also faces legal charges, including some originating from the investigation into the assassination in 2007 of the former prime minister Benazir Bhutto, who also spent time in self-imposed exile in Dubai before returning.

The flight from Dubai came after several failed promises to return in recent years. Musharraf announced in early March he would lead his party, the All Pakistan Muslim League, in May elections.

Musharraf briefly met reporters in Dubai before heading to the airport wearing a white shalwar kameez – the traditional loose-fitting outfit in Pakistan – and sandals from the country's Peshawar region near the Afghan border. He mingled with supporters on board the plane on the way to Karachi as some of them chanted slogans for his party.

Musharraf took power in a 1999 coup and was forced to step down in 2008 amid growing discontent over his rule. He has since lived in Dubai and London.

His decision to return was given a boost last week when a Pakistan court granted him pre-emptive bail – essentially preventing his immediate arrest – in three cases in which he is implicated, including the death of Bhutto. He has 10 days to appear in court. He has dismissed the various charges as baseless.

On Sunday, the country's election commission appointed a former high court chief justice nominated by the country's outgoing ruling party to serve as caretaker prime minister in the runup to the election. The commission chose Mir Hazar Khan Khoso out of four nominees, two submitted by the recently ruling Pakistan People's party and two by the main opposition Pakistan Muslim League.