LONDON — The last time that Nawaz Sharif had close dealings with the Pakistani Army, soldiers handcuffed him and imprisoned him in an ancient fort overlooking the Indus River, physically dragging him from office in a coup.

Now that Mr. Sharif is poised to return as prime minister of Pakistan for the third time in 20 years, the success of his relationship with the generals will revolve around two related questions: Has he changed? And have they?

Many analysts believe he has new tools at his disposal, and in recent days he has played down the prospect of conflict with the army. Much of the hopeful talk surrounding his landslide victory on Saturday is focused on how Mr. Sharif seems different — more mellow, less authoritarian — than during his two previous stints as prime minister in the 1990s. And he returns to power with a mandate from Pakistani voters who have apparently given his party a near outright majority in Parliament.

When the military deposed him in 1999, he had earned the displeasure of its leadership for his outreach to India — which this week he promised to renew — as well as his clumsy attempt to fire the army chief, Gen. Pervez Musharraf. Since then, the military has faced several humiliations, including the American commando raid that killed Osama bin Laden in 2011, that have hurt its public image. And under Gen. Ashfaq Parvez Kayani, the army has shown little public appetite for openly meddling in politics, much less mounting another coup.