Donald H. Rumsfeld is stepping down as defense secretary and former CIA Director Robert Gates will be nominated to take his place.

President Bush made a formal announcement Wednesday after holding a press conference to offer his take on the midterm election.

"Bob is one of our nation's most accomplished public servants," Bush said in the Oval Office, where he was flanked by both men. "Bob understands the challenges facing our nation in Iraq. ... He has traveled to Iraq and met with the country's leaders and our military commanders on the ground. He'll provide the department with a fresh perspective and new ideas on how America can achieve our goals in Iraq.

"He has my confidence and my trust, and he will be an outstanding secretary of defense," Bush said.

Gates, who is currently the president of Texas A&M University, met with Bush on Sunday at the president's ranch in Crawford, Texas. Noting that his time at the university was the best in his life, he said he had not expected to come back to Washington to serve under a seventh president but the challenges facing the United States were too much to ignore.

"The United States is at war, in Iraq and Afghanistan. We're fighting against terrorism worldwide. And we face other serious challenges to peace and our security. I believe the outcome of these conflicts will shape our world for decades to come," he said.

"Because our long-term strategic interests and our national and homeland security are at risk, because so many of America's sons and daughters in our armed forces are in harm's way, I did not hesitate when the president asked me to return to duty," Gates added.

Bush also offered hearty praise to his outgoing secretary, patting Rumsfeld on the back after he spoke.

"Few will forget the image of Don Rumsfeld as he helped rescue workers carry the victims from the rubble of the Pentagon on September the 11th, 2001," Bush said. "In the weeks that followed, he directed the effect to plan our nation's military response to an unprecedented attack on our soil. Under his leadership, U.S. and coalition forces launched one of the most innovative military campaigns in the history of modern warfare."

Rumsfeld said many people have not given Bush the credit he's due for leading the charge into Iraq.

"The great respect that I have for your leadership, Mr. President, in this little-understood, unfamiliar war, the first war of the 21st century -- it is not well-known, it was not well-understood; it is complex for people to comprehend. And I know with certainty that, over time, the contributions you've made will be recorded by history," he said.

While always great for a quote, Rumsfeld has had a tempestuous relationship with the media as well as Democrats on Capitol Hill and even some military officials in Washington. He seemed more subdued than usual, but demonstrated his irascible nature by paraphrasing the late British Prime Minister Winston Churchill.

"I have benefited greatly from criticism, and at no time have I suffered a lack thereof," he said.

Rumsfeld, Bush's sole defense secretary in six years of leadership, is the first administration casualty after a midterm congressional election that sent at least 28 House Republicans packing and left the future of the Senate in limbo.

Earlier in the day, Bush called Rumsfeld a trusted friend and patriot who had served his country well.

"Now after a series of thoughtful conversations, Secretary Rumsfeld and I agreed that the time had come for new leadership at the Pentagon," Bush said in an East Room press conference scheduled Tuesday night after election returns showed an incoming Democratic House majority.

"Don Rumsfeld has been a superb leader during a time of change. Yet he also appreciates the value of bringing in a fresh perspective during a critical period in this war," he said.

Rumsfeld's departure was a surprise to many after his office gave no indication earlier in the day that the congressional outcome would impact his decision. Just last week, Bush said he had full faith in Rumsfeld. Then again, he acknowledged Wednesday that he thought Republicans would retain the House.

Bush was also questioned about whether he was caught in a fib when he told The Associated Press last week that he planned for Rumsfeld to stay on as defense secretary through the end of his term.

Bush said he misled the reporter because he "didn't want to inject a major decision about this war in the final days of a campaign. And so the only way to answer that question and to get you onto another question was to give you that answer."

But the president said he wasn't being misleading in praising Gates' long history of organization and national security credentials.

"He's served six presidents, from both political parties, and rose from an entry-level employee in the CIA to become the director of central intelligence," Bush said. Gates would have to be confirmed by the Senate, whose majority will be determined by the race in Virginia, the sole remaining contested election.

The president noted that Gates is a member of the Iraq Study Group, a congressionally commissioned panel co-chaired by former Secretary of States James Baker and former Democratic Rep. Lee Hamilton.

The ISG is soon to deliver a set of recommendations about the direction that needs to be taken in Iraq. Bush said he is meeting with the panel chairmen next week, and expected Gates to play a strong role in the recommendations to come from the panel.

Gates "is a steady, solid leader who can help make the necessary adjustments in our approach to meet our current challenges," Bush said.

The president said despite the changes expected at the Pentagon, he did not think Tuesday's election victories were a mandate to leave Iraq without succeeding there.

"I'd like our troops to come home too, but I want them to come home with victory," Bush said. "I mean, I can understand Americans saying, 'Come home.' But I don't know if they said: 'Come home and leave behind an Iraq that could end up being a safe haven for Al Qaeda. I don't believe they said that,'" he said.

Bush told Iraqis not to be fearful by the changes in the United States or its own halting steps to democracy. He also warned terrorists not to start celebrating as a result of Rumsfeld's departure.

"Do not be joyful. Do not confuse the workings of our democracy with a lack of will. Our nation is committed to bringing you to justice. Liberty and democracy are the source of our strength," Bush said.

"To our men and women in uniform: don't be doubtful. America will always support you. Our nation is blessed to have men and women who volunteer to serve and are willing to risk their own lives for the safety of our fellow citizens," he said.

Click here to visit YOU DECIDE 2006, FOXNews.com's complete election center.

Rumsfeld, a former Navy pilot and congressman who also served as secretary of defense under President Gerald Ford, led the Defense Department response to the terrorist attacks of Sept. 11, 2001. On that day, 184 people died when hijackers crashed American Flight 77 into the Pentagon.

Shortly afterward, the United States invaded Afghanistan, liberating 25 million people. Coalition forces entered Iraq in March 2003, which resulted in the downfall of Saddam Hussein but caused internecine fighting that critics say has led to a civil war with American soldiers in the middle of it.

Rumsfeld is responsible for a major overhaul at the Defense Department. The restructuring called for a significant reorganization of the worldwide defense command structure and an expansion of U.S. special operations forces that are more closely integrated into contingency planning.

He has also initiated a global restructuring of U.S. forces to reflect the shift in military challenges globally. He also oversaw recommendations for the largest round of base readjustments in U.S. history.

Rumsfeld plans to deliver a long-scheduled speech on the global War on Terror at Kansas State University on Thursday. A Pentagon spokesman said he did not know whether Rumsfeld would address the midterm election results in that speech.