Stanley, a retired Marine Corps major general, has served as the undersecretary of defense for personnel and readiness since February 2010. He will leave in the next two weeks, Doug Wilson said.

Jo Ann Rooney, the principal deputy undersecretary for personnel and readiness, will serve as acting undersecretary until a replacement is nominated and confirmed by the Senate.

“Dr. Stanley was motivated above all by a sense of commitment to the highest standards of service to the men and women in uniform he served,” Wilson said in a written statement announcing the resignation. “He felt he had done his utmost to carry out the mandate he was given, and that he had arrived at the point where the next steps could be carried out most effectively by a successor. His decision to resign was his own.”

The undersecretary for personnel and readiness serves as the senior policy advisor to the secretary of defense on recruitment, career development, pay and benefits for 1.4 million active duty military personnel, 1.3 million reserve-component personnel and 680,000 defense civilians.

Stanley spent 33 years in the Marine Corps, with his last as deputy commanding general of Marine Corps Combat Development Command in Quantico, Va. Previously, he commanded the Marine Corps Air Ground Combat Center at Twentynine Palms, Calif., and he also served as the Marine Corps’ assistant deputy chief of staff for manpower and reserve affairs and as director of public affairs.

Stanley also commanded the 1st Marine Regiment.

In his resignation letter to Panetta, Stanley noted the honor of serving as undersecretary, and said what he really loved was serving the men and women of the department. “I’m not ashamed to say that I love them all,” he wrote to Panetta. “It is with that thought that I am tendering my resignation.”

Stanley stressed that he believes personnel and readiness is on the right path.

“I’ve asked them to ensure that compassion is ever present in their work,” he wrote. “I’ve joked about the bureaucracy in the Pentagon, but with the understanding that there is some good in having a bureaucracy that is focused on taking care of our troops, families, retirees and civilian employees.

“The Department of Defense, and our nation, is blessed to have you at the helm,” Stanley continued. “I owe an eternal debt of gratitude to you, former Secretary [Robert M.] Gates and to our Commander-in-Chief, President Barack Obama, for this truly unique opportunity to serve.”

The defense secretary, who is traveling in Asia, believes that Stanley has been a devoted public servant during his entire professional career, Wilson said.

Panetta “has praised Dr. Stanley as an advocate for America’s men and women in uniform,” Wilson said. “The secretary has accepted his resignation, and upon his return will personally convey his appreciation for Dr. Stanley’s service as part of the Pentagon’s senior leadership team.”