"Acting Secretary of Defense Patrick Shanahan, who has done a wonderful job, has decided not to go forward with his confirmation process so that he can devote more time to his family," Trump tweeted.
"I thank Pat for his outstanding service and will be naming Secretary of the Army, Mark Esper, to be the new Acting Secretary of Defense. I know Mark, and have no doubt he will do a fantastic job!"
Shanahan called it a "deep honor and privilege" to work for the Department of Defense.
"I am proud of the work accomplished over the last two years. With the leadership of President Trump and the bipartisan support of Congress, the Department has made significant progress rebuilding and modernizing the military to compete with China and Russia," he said.
Shanahan said he withdrew his name from consideration for the role to protect his children from focus on an FBI investigation into a violent domestic dispute between him and his former wife nine years ago. The probe stemmed from a background investigation related to his possible nomination and confirmation hearing.
Both Shanahan and his former wife, Kimberley Jordinson, told police they had been punched by the other. Both also denied being violent in the incident.
Shanahan released a statement Monday calling the altercation a "painful and deeply personal family situation." He said he never laid a hand on Jordinson.
"Our story is not dissimilar to those of the many families facing the difficult challenges that come when a loved one struggles with substance abuse and other emotional issues as is the case with my former wife," he said.
"I wish nothing but the best for her and regret that my children's privacy has been violated and they are being forced to relive a tragic situation that we have worked so hard as a family to put behind us."
Trump told reporters Tuesday that Shanahan planned to take time off "for family matters," adding that he didn't ask him to withdraw his name from consideration. The president said he learned of the FBI investigation Monday.
"Acting Secretary Shanahan has proven over the last several months that he is beyond qualified to lead the Department of Defense, and he will continue to do an excellent job," she said at the time.