WASHINGTON — Just three months after losing his campaign to be president of the United States, a politically wounded and weary Senator John Kerry took a routine fact-finding tour of the Middle East. It was one of countless overseas trips Kerry had taken in his two decades in Congress. But this time, those accompanying the Massachusetts Democrat noticed something was different.

On the return leg of the trip, during a late night stroll to the Brandenburg Gate in Berlin, a crowd spontaneously gathered around the former Democratic nominee for the White House. They reached to shake his hand. They snapped his photo. They peppered him with questions about the Iraq War. He had attracted similar swarms in Israel, Iraq, Jordan, and the Palestinian territories.

“It was striking how people in the streets came up to him everywhere,” recalled a close confidante intimately familiar with the trip. “It was new and different, and it was noticed by the leaders in the region.”

The 2004 presidential campaign had significantly raised Kerry’s profile around the world, an international stature that helped Kerry climb out of the darkness after his defeat at the hands of President George W. Bush and allowed him to reset the trajectory of his public career.

On Friday, President Obama nominated Kerry as the next secretary of state, a post for which friends and colleagues say he is well suited. The son of a Foreign Service officer has thought deeply about matters of war and peace, and has logged thousands of hours traveling the globe on various diplomatic quests.

As a boy living in Europe during the Cold War, Kerry biked around communist East Germany despite his father’s warnings and hunted for D-Day casings on the beaches of Normandy. As a young man, the Vietnam War-veteran-turned- war-protester spoke out passionately about the tragic costs of geopolitical miscalculation.

STEPHEN CROWLEY/NEW YORK TIMES/FILE

Kerry persuaded Hamid Karzai, the president of Afghanistan, to agree to a runoff election after he had prematurely declared himself the winner.

“You have a guy who, from his earliest days, has been schooled in America’s international role, both in war and in peace making,” said Max Cleland, a former senator from Georgia and a close friend of Kerry’s. “He was born to be secretary of state. What you’ve got here is a very rare human being who has been through the throes of the damned in war and in politics in a presidential election, and who has survived it all to come out on top.”

In the eight years since his 2004 run, Kerry, freed from the expectations of capturing the presidency, took a cue from his Senate colleague Ted Kennedy following the end of his presidential aspirations and focused again on the often unglamorous work of being a senator from Massachusetts, securing federal funds for Bay State road projects amid other duties.

But his real calling remained foreign policy, and he sought to play a leading role in key debates from Iraq to Afghanistan. After he ascended to the chairmanship of Foreign Relations in 2009, he shepherded a nuclear arms pact with Russia and persuaded Afghan President Hamid Karzai to agree to a runoff election after he had prematurely declared himself the winner. There were also setbacks, most recently the Senate’s failure to ratify an international treaty he fought for on treatment of the disabled.

“It takes a certain period of time to get over losing the presidency, but eventually he accommodated quite well,” said Tom Hayden, a political activist and former California legislator. “The chairman of the Senate Foreign Relations Committee is not like a presidency in the wings, but its reach, its powers, its personnel, is enormous. In his mind, he was operating a virtual secretary of state office.”

As an adult, Kerry’s induction into foreign affairs began during the tumult of the Vietnam War. The idealistic Yale University senior enlisted as a naval officer at the urging of William Bundy, assistant secretary of state for Far Eastern affairs in the Kennedy administration and the uncle of one of his roommates.

But Kerry began questioning the country’s mission in Vietnam even before setting foot in the war zone, remarking in his 1966 graduation speech, “What was an excess of isolationism has become an excess of interventionism.” Few protested the war at the time, and Kerry felt he had little choice but to serve in order to see first-hand what was happening.

His critique of the war continued in his letters home. He tried to put himself in the shoes of the occupied and wondered what it would be like “to have to bend to the desires of a people who could not be sensitive to the things that really counted in one’s country.”

By the time Kerry returned from Vietnam – discharged six months early with three Purple Hearts, a Bronze Star, and a Silver Star as commander of a riverine unit in the Mekong Delta – he had developed a deep distrust of government.

Yet he aspired to lead it, first weighing a 1970 run for Congress on an antiwar platform. Instead, in 1971, Kerry became the face of Vietnam Veterans Against the War and organized a national protest in Washington. In a historic prelude to the role he would eventually play in the Senate, the 27-year-old Kerry delivered powerful testimony before the Senate Foreign Relations Committee he would later chair, in which he famously asked, “How do you ask a man to be the last man to die for a mistake?”

The following day, the decorated Navy lieutenant lobbed his ribbons over a fence in front of the Capitol during a demonstration he orchestrated. The events instantly catapulted Kerry to national fame.

Four decades later, Kerry proudly displayed his war medals, pinning them to the breast of his tuxedo at the white-tie Gridiron Club dinner in Washington last March.

There remains bitterness toward Kerry on the part of some who believe his antiwar stance and allegations of American atrocities in Vietnam made him unsuitable for the presidency and now secretary of state.

But even those who were on the opposite side of the Vietnam debate now agree that Kerry is among the most qualified for the Cabinet post. “I didn’t approve of what he did, but I understood the protesters quite well,” said Melvin Laird, , former secretary of defense during the Nixon administration, whose son also protested the war. “I wish him very well.”

Thomas Vallely, a Kerry confidant and director of the Vietnam Program at Harvard’s Kennedy School, believes that more than any experience, the war years molded Kerry’s current approach to the world.

“To me the most important thing for our secretary of state is to live in and understand the reality of the world that we’re in – not the myth that’s created about the world that we’re in. And he has that capacity,” he said.

Nevertheless, some are skeptical of Kerry’s history of shifting positions, accusing him of being opportunistic and changing with the political winds. For example, Kerry invoked the prospect of another Vietnam to oppose war in 1990 after Saddam Hussein invaded Kuwait, but then voted to authorize the use of force to overthrow the Iraqi leader in 2002 as he was preparing to run for president. He later voted against funding to continue the war, exposing himself to criticism by Bush as a flip-flopper.

Supporters of the former Middlesex County prosecutor and Yale debater say he has an academic tendency to examine and see an issue from all angles, frustrating even his staff who often do not know how he will vote on an issue until he reaches the Senate floor.

Those close to him said they believe he made a conscious decision after the 2004 presidential race to leverage his new influence in the international arena. “He was somebody,” said Shahid Ahmed Khan, a board member of the Pakistani American Public Affairs Committee who served as finance co-chair of Kerry’s presidential bid and later traveled with him to India and Pakistan.

Kerry’s name was first floated as possible secretary of state after President Obama’s 2008 election. “In 2008 he wanted to be, but one thing about Senator Kerry: He does not lobby for this position. He did not lobby last time and he did not lobby this time,” said Khan, who runs a consulting firm in Framingham.

Kerry supporters say his personal history makes him particularly fitted for the nation’s highest diplomatic post at a time when the United States is extracting itself from Afghanistan. Last month, Kerry, who initially supported the Afghan war while campaigning for president, voted for an accelerated withdrawal of troops.

Michael Dukakis, a former governor of Massachusetts and another Democratic nominee for president for whom Kerry worked as lieutenant governor, said he hopes Kerry’s nomination will mean an opportunity for the United States and its allies to strengthen the peace-keeping capacity of international institutions.

“I don’t know when we decided we were going to be the world’s policeman, but we don’t do it very well and we can’t afford it,” Dukakis said.

Close observers also expect Kerry to focus international attention on global climate change, given his long involvement with the issue. Kerry has attended at least seven international meetings on climate change over the past two decades. While a bipartisan effort he spearheaded in the Senate in 2010 to try to enact domestic climate change legislation failed, he remains committed to helping find a breakthrough.

But former senator Gary Hart of Colorado, who has also spent decades on the international stage, cautioned that as secretary of state, Kerry may be frustrated to find that in some instances he has less influence than he does now.

“So much of that job is ceremonial,” Hart said. “You still have to push the cookies and go to all the receptions. A free-floating Senate leader can bypass that to a degree.”

The challenges awaiting Kerry were on display Thursday when he chaired a hearing on the deadly attack on a US consulate in Libya in September.

After grilling the State Department witnesses on why they turned down requests for more diplomatic security, Republican Bob Corker of Tennessee turned to Kerry.

“The culture within the department to me is one that needs to be transformed,” Corker said. “This committee can help. Maybe the next secretary of state can help.”