Gen. Martin Dempsey stepped down as the military's top officer Friday, after four tumultuous years of war, budget cuts and the strains of combat on a battle-worn force.

He turned over his responsibilities to Marine Gen. Joseph Dunford, who is taking over at a crucial point, as tensions surge with Russia, U.S. troops wage war against militants in Iraq, Syria and Afghanistan, and the effort to train and equip Syrian rebels struggles to find a footing.

The transfer of responsibility took place during an afternoon of marching bands, Irish songs, speeches and military pomp Friday, under cloudy skies at Joint Base Myer-Henderson Hall, Va., with President Barack Obama and other senior defense leaders and military commanders in the audience.

Dempsey, a well-respected, combat-hardened officer, took over as Obama's top military adviser in September 2011, as the war in Afghanistan was beginning to wind down and the last U.S. troops were coming out of Iraq. At the time, one of his key concerns was the impending budget cuts, and how the military services would get leaner without harming their readiness for war.

But times rapidly changed, as he worked to help an often divided administration reach agreements on a number of contentious issues, including the pace of the military drawdown in Afghanistan, the scope of the military missions in Iraq and Syria, and the types of aid to provide Ukraine in its battle against Russian separatists.

At the same time, Dempsey also worked with the military services to combat the effects of years at war on U.S. forces, who have seen suicides and sexual assaults spike, while veterans struggle to find jobs and get the medical care they need.

Obama praised Dempsey as a leader who was committed to insuring the military became a more versatile and responsive force.

"I chose him because he had the steady hand we needed in this moment of transition -- as we tackle emerging threats and support so many of our troops as they transition to civilian life," Obama said. "But perhaps most of all, I chose Marty because he's a leader you can trust.  Marty, you've always given it to me straight.  I can't tell you how much I've appreciated your candor and your counsel."

Dempsey, who keeps a cigar box filled with 132 cards on his desk identifying each of the soldiers whose lives were lost under his command in Iraq, ended his remarks with the three words inscribed on the box.

"It has been my privilege to wear the cloth of our nation.  To all who will continue to serve after me, I ask only this in parting," Dempsey said. "Make it matter."

In one poignant moment, Dempsey's son Chris -- an Army major -- read his father's retirement order, his voice breaking with emotion. Dempsey later joked that for those who were betting on how long it would take for him to cry during the ceremony -- it was that moment when his son spoke.

At the end of the ceremony, he and his wife Deanie danced briefly to their wedding song, "Close to You," in honor of their recent 39th anniversary. To conclude, Dempsey took the microphone -- as he often does -- and sang the popular Irish song, "The Parting Glass."

Dunford, who until Thursday was serving as the Marine Corps commandant, spoke briefly, saying he is looking forward to working with the other military leaders "to tackle the challenges on our watch."

Prior to his short stint as commandant, he served as the top U.S. military commander in Afghanistan.

The last Marine to hold the office of chairman was Gen. Peter Pace, from 2005 to 2007.