KABUL, Afghanistan — Today, they are representatives of three central parties to the Afghan war, caught up by a frenzied effort to find an endgame to decades of violence.

But during the last stretch of peace their generation has known, in the 1970s, the three young Afghans — Ashraf Ghani, Zalmay Khalilzad and Sher Mohammed — were all busy finding themselves while studying on scholarships abroad.

During those years, Mr. Ghani and Mr. Khalilzad, now the Afghan president and the chief American peace envoy, were completing degrees in Lebanon at the American University in Beirut, a vibrant hub of ideologies and intellects during a turbulent time in the Middle East. They enjoyed the Mediterranean beaches, went to dances and met their future wives.

The third Afghan, now known as Sher Mohammed Abas Stanekzai, the chief negotiator for the Taliban, spent those years in military fatigues at the foothills of the Himalayas, training at India’s most prestigious military schools. On breaks, his batch of young Afghans would find themselves in the hills of Kashmir, or on the sets of Bollywood films hoping for a photo with the stars.

Each of their lives captures an arc of the long Afghan conflict. And their differing paths and personalities are now converging at center stage of a desperate geopolitical drama.

To end a war that has lasted, in one way or another, for 40 years is no easy task. And though Mr. Ghani, 69, and Mr. Khalilzad, 67, have a remarkable amount of shared history, they have increasingly been at odds over how to approach the Taliban.

The two first met as teenagers, 53 years ago, on an exchange program in the United States, Mr. Ghani recently said.

After both men finished degrees at the American University in Beirut, Afghanistan’s descent into war in the late 1970s put them in the United States again. Mr. Khalilzad earned his doctorate at the University of Chicago, and Mr. Ghani earned his master’s and doctoral degrees at Columbia University, where Mr. Khalilzad started working as an assistant professor.

But even in their student days, the two had notably different styles.

During college in Beirut, Mr. Ghani was more socialist-leaning, and Mr. Khalilzad more capitalist. In his speeches, Mr. Ghani has hailed Mohammad Daoud, who dethroned his own cousin the king in 1973 to declare Afghanistan a republic and himself its president.

In one of his books, Mr. Khalilzad made a point of recalling Mr. Daoud unfavorably. The first time he encountered the future president, he wrote, was when he saw Mr. Daoud leave his vehicle on a highway to beat up a driver who wasn’t getting out of the way and then bite off the man’s left ear.

“They have two very different personalities,” said Akram Fazel, who overlapped with Mr. Ghani and Mr. Khalilzad at American University in Beirut. “Dr. Ghani was working more on self-reliance. He was very focused on his books, and he kept to himself. Dr. Khalilzad was more about consensus and participatory ways — and for him life wasn’t just studies, it was about enjoyment, too.”

Those who have known the two men say part of the current chill in the relationship stems from a fundamental clash in how they operate, as well. By nature, Mr. Ghani is firm in his own ideas, while Mr. Khalilzad is more about patching together a compromise from what is in front of him.

Today, Mr. Ghani and his aides are frustrated by what they see as their American partners’ rushing into a deal that could ensure them an exit but that could unravel a fragile Afghan state.

Mr. Ghani’s advisers worry that Mr. Khalilzad is cooking up an endgame with the Taliban that is skirting around the Afghan government.