David Maraniss, an associate editor of The Post, is the author of “First in His Class: A Biography of Bill Clinton” and the forthcoming “Barack Obama: The Story.” This is the fourth column in an occasional series on the 2012 presidential candidates’ political lives.

Before his first speech at an antiwar rally, the one that helped propel him toward the presidency, Barack Obama shifted uneasily in his chair waiting for the program to begin. Something was bugging him. The date was Oct. 2, 2002, when the drums for war in Iraq were growing louder. The scene was Federal Plaza in Chicago’s Loop, where a thousand or so people had gathered at noon, some holding placards that proclaimed “War Is Not an Option.” On stage with the state senator from Hyde Park were religious leaders, union officials, students and peace activists.

Obama sat near Bettylu Saltzman and Marilyn Katz, key figures in Chicago’s liberal network. Katz moderated the rally. Saltzman, in charge of rounding up speakers, had placed the call that brought in Obama, who was already plotting his rise out of Springfield to the U.S. Senate. Whether his appearance at the rally would help or hurt his political fortunes was a topic he and his advisers had discussed intently, but that was not bothering him now. It was the music that was getting to him. One after another came the baby-boom anthems of the Vietnam era — “Blowin’ in the Wind” and “Where Have All the Flowers Gone?” and “Give Peace a Chance.”

At one point Obama turned to Saltzman and Katz and asked plaintively, “Couldn’t they think of something else to play?”

That moment 10 years ago illuminated more than musical tastes. It offers another way to understand President Obama’s relationship with war and peace and the military. The simple fact that he was there, speaking out against Iraq so early, proved crucial to his support among ­MoveOn.org and other antiwar groups during the 2008 presidential primary. But his lament about the music, along with the content of his speech (he pointedly said he was not against all wars, just a war in Iraq), offered more predictive insight into his behavior as president. On a personal level, he seems at ease in the presence of soldiers and sailors, more so than he would be in the midst of an antiwar rally; on a policy level he seems increasingly comfortable wielding the powers of a commander in chief.

Obama is the first president to whom Vietnam is ancient history. He carries none of the psychological baggage of that war, for better or worse. Every young man in the baby-boom generation of Bill Clinton and George W. Bush had to deal with Vietnam somehow, but by the time Obama came of age, the war and the draft were over. His liberal mother felt at home in the peace movement, and he took many characteristics from her, but he also chafed at her idealistic naivete, which he viewed as a relic of the ’60s. From an early age he wanted to be harder and cooler than his mother, less Pollyannaish, more pragmatic. His use of the military option in his foreign policy reflects that dual sensibility. Clinton grew up wanting to be JFK, but Obama thinks more like him.

It was no accident that, during his surprise visit to Afghanistan a few days ago, the president referred to the military men and women there as the new “greatest generation,” skipping over Vietnam again. Obama feels more affinity toward his grandfather’s generation (Stan Dunham fought in Europe during World War II) than to his mother’s, or he at least finds it more culturally appealing. He is an avid viewer of the television show “Mad Men” and told me that some of the characters remind him of his grandparents, with whom he lived as a teenager.

The cultural geography of those formative years also shaped his perspective. Obama was in Honolulu then, surrounded by military installations. Hickam Air Force Base, Schofield Barracks, Fort Shafter, Pearl Harbor Naval Station and Hawaii Marine Corps Base were all part of his adolescent environment. He grew up comfortable with the military culture, not alienated from it. Some friends came from military families. One of his buddies dated an admiral’s daughter, and they would borrow the old man’s car to tool around the island.

Which leads to the least-appreciated aspect of Obama’s connection to the military — race. That buddy was known as a hapa, the Hawaiian term for someone of mixed heritage; like Obama, he had one black parent. Oahu was a diverse and colorful place, a mix of cultures and languages, but fewer than 1 percent of its residents were black, and almost all of those were connected to the military.

In Hawaii as in the rest of the country, the military served as an important tool of racial advancement, better integrated and offering a more level playing field than any other large institution. Look into the faces of the soldiers who greeted Obama in Afghanistan this month, black and Latino and white, and you can almost feel the visceral connection with a president who has a diverse background. No more “Blowin’ in the Wind.” To get Obama grooving to an antiwar anthem, Marvin Gaye’s “What’s Going On?” would have been a better choice.