WASHINGTON — The outreach began more than a year ago when Barack Obama, the antiwar candidate who had never served in the military, turned to a group of young officers just out of active duty for a fresh perspective on America’s two wars.

“He asked a lot of questions,” recalled one of the officers, Craig M. Mullaney, a former Army Ranger in Afghanistan who in campaign travels with Mr. Obama told him how his platoon of 35 men had vaccinated camels, worked with tribal elders and been in charge of security for a province the size of Vermont.

That early outreach has since given way to a carefully planned campaign by Mr. Obama to build trust with the military and avoid the mistakes that hobbled Bill Clinton, the last Democratic commander in chief. By Thursday, when the president met for the first time with the Joint Chiefs of Staff in “the tank,” the secure Pentagon conference room, the campaign had progressed to the point that participants left “comforted,” as one put it, about Mr. Obama’s willingness to work with them.

Pentagon officials say they have been relieved that Mr. Obama has so far proceeded slowly on two campaign promises: to pull all combat troops out of Iraq within 16 months and to allow gay men and lesbians to serve openly in the military.

Mr. Obama’s aides have signaled that they will avoid an early conflagration involving the military and will wait for months before moving to repeal the 16-year-old “don’t ask, don’t tell” policy that requires gay men and lesbians in the services to keep their sexual orientation secret.

“It’s moving prudently,” said Denis McDonough, a top foreign policy aide to Mr. Obama. “I think we’ve seen what happens when you address important policy issues imprudently. It’s not in our interest and it’s not the style of this president.” (Mr. Clinton’s push in 1993 to have gay men and lesbians serve openly created a storm at the Pentagon; “don’t ask, don’t tell” was the compromise.)

Mr. Obama’s cultivation of the military has reached the point that it is already causing unease among some members of his liberal base, who say they will hold him to his promise on troop withdrawals and pressure him to move more quickly on “don’t ask, don’t tell.”

The nation’s largest gay rights lobbying group has called on the president to develop a plan to end “don’t ask, don’t tell” within his first 100 days, and another group is asking that Mr. Obama push for repeal by the end of the year.

“I’d be very concerned if they don’t seize this opportunity in 2009,” said Aubrey Sarvis, the executive director of the Servicemembers Legal Defense Network, an advocacy group that represents gay men and lesbians in the military. “We take the president at his word, and we plan to keep his feet to the fire.”

The military is not a monolith, but it is safe to say that Mr. Obama was not its candidate in the 2008 election. His antiwar comments ignited the left but struck many in the armed services as naïve. His Republican opponent, Senator John McCain, was a war hero.

Late last year, a survey by The Military Times, while not representative of the military as a whole, found much uncertainty and even pessimism about Mr. Obama among 1,900 active-duty respondents. Not only had Mr. Obama never served, he had one of the most liberal voting records in the Senate and a background that seemed culturally at odds with the more conservative traditions of the armed forces.

And although Mr. Obama’s grandfather served in Patton’s Army during World War II — a fact the candidate brought up on the campaign trail — his own exposure to the military was scant. To educate himself and to establish credentials, he reached out during the campaign, as candidates traditionally do, to retired generals, among them President George W. Bush’s first secretary of state, Colin L. Powell, who endorsed him.

The group included Mr. Mullaney, 30, a former Rhodes scholar and the author of a coming book about Afghanistan, “The Unforgiving Minute,” who worked as an Obama campaign national security aide in Chicago; Matthew Flavin, 29, an Amherst graduate and former Navy intelligence officer who served in Iraq, Afghanistan and Bosnia and who worked as a campaign national security aide in Washington; and Phillip Carter, 33, an Army veteran and adviser to the Iraqi police in Baquba in 2005 and 2006, who was in charge of veterans’ outreach for the Obama campaign.

The three answered to Mr. McDonough, 39, and Mark W. Lippert, 35, a longtime Obama foreign policy adviser and a former intelligence officer for the Navy Seals in Iraq.

The group is now beginning to spread through the new administration. Mr. Lippert is chief of staff of the National Security Council at the White House; Mr. Flavin is a staff assistant on the National Security Council legal team; Mr. Mullaney and Mr. Carter are waiting for jobs.

Military officials say that a big step in Mr. Obama’s campaign to build their trust was his retention not only of Mr. Bush’s defense secretary, Robert M. Gates, but also his appointment of three other military men to top positions. Gen. James L. Jones, a retired Marine commandant, is Mr. Obama’s national security adviser; Gen. Eric K. Shinseki, the retired Army chief of staff, is secretary of veterans affairs; and Dennis C. Blair, a retired admiral, is director of national intelligence.

“He has in his cabinet a soldier, sailor and marine,” Gen. James T. Conway, the Marine Corps commandant, told reporters last week. “I find that pretty encouraging.” (Technically, General Jones is not a member of the cabinet.)

Pentagon officials also point to early gestures by Mr. Obama that have been symbolic but important to them. Anyone in the military could tell that Mr. Obama took the time to practice the first, crisp salute that he executed on Jan. 20. That evening the new president spoke by video feed to American troops in Afghanistan at the Commander-in-Chief Ball; the weekend before, he laid a wreath at the Tomb of the Unknowns at Arlington National Cemetery and visited wounded soldiers at Walter Reed Army Medical Center.

There are, of course, difficult times ahead. Not least, Mr. Obama will have to make tough choices about cuts in the military budget. “The services are going to be told ‘no’ a lot more often,” said Andrew F. Krepinevich Jr., a military expert at the Center for Strategic and Budgetary Assessments, a research group. And the president must make even harder decisions about how to meet his promise to have combat troops out of Iraq within 16 months.

Many at the Pentagon consider the 16-month timetable too risky, but the left expects Mr. Obama to deliver.

“We have no reason to believe that he is backing off of his pledge, and we don’t think that’s incompatible with having a good conversation with the generals,” said Eli Pariser, the executive director of MoveOn.org, a liberal group that opposed the war.

Still, Mr. Pariser said, “he knows that there are millions of Americans who voted for him on his pledge to bring the troops home.”

A version of this article appears in print on , on Page A14 of the New York edition with the headline: Building on Campaign Effort, Obama Carefully Cultivates Military. Order Reprints|Today's Paper|Subscribe