Donilon, 58, has spent four years in the White House. Mr. Obama praised him for having "shaped every single national security policy of my presidency," including the renewed U.S. focus on ties with Asia.
The president also announced the nomination of former White House aide Samantha Power to replace Rice as U.S. ambassador to the United Nations. Power is a human rights advocate and expert on genocide.
It's unclear whether the changes signal a significant shift in the president's foreign policy, particularly in Syria, where the U.S. is being pressured to act against President Bashar Assad.
Rice, a close confidante of the president, came under fire from Republicans as part of the investigations into the deadly attack on a U.S. compound in Benghazi, Libya. She said in TV interviews that the attacks were likely spontaneous, which was later proven incorrect. Rice was relying on talking points from the intelligence community when she made those comments.
Mr. Obama considered nominating Rice as his second-term secretary of state, but she withdrew amid the GOP criticism, saying she didn't want her confirmation fight to be a distraction for the White House. The president instead nominated John Kerry, who easily won confirmation from his former Senate colleagues.
Rice's new post as national security adviser did not require Senate confirmation.
Neither Mr. Obama nor Rice mentioned the Benghazi controversy during Wednesday's ceremony. Rice said she looked forward to working with lawmakers from both parties "to protect the United States, advance our global leadership and promote the values Americans hold dear."
Rice's selection was greeted by a muted response from some Republicans who had earlier accused her of being part of an administration cover-up in the Benghazi attacks.
Arizona Sen. John McCain, one of Rice's harshest critics, wrote on Twitter Wednesday that he disagreed with her appointment but would "make every effort" to work with her on important matters. And Tennessee Sen. Bob Corker, the top Republican on the foreign relations committee, said he had spoken with Rice and looked forward "to working with her on shaping important foreign policy and national security issues."
The White House official said Donilon is expected to stay on the job until early July, after Mr. Obama wraps up overseas trips to Europe and Africa, as well as a summit in California later this week with Chinese President Xi Jinping.
The Associated Press contributed to this report.