Two days after the Tucson mass shooting, Ashley Turton, the wife of Dan Turton, Obama's liaison to the House of Representatives, died when her car struck a wall in their garage, igniting a flash fire.
Several members of Obama's staff went to be with their colleague, and with the couple's twin toddlers and year-old baby.
The White House was already preparing for another funeral later in the week for diplomat Richard C. Holbrooke.
"I think we're all searching for meaning here," said one senior administration official who, like others, described the personal scene on the condition of anonymity.
Obama's search began hours after he heard of the Tucson shootings. Six people were dead and 13 wounded, including Rep. Gabrielle Giffords, D-Ariz. One of the first people he reached out to after calling in his speechwriter was a young clergyman on his staff, Joshua DuBois.
A Pentecostal preacher in his spare time, DuBois set aside the e-mail devotionals he had prepared for Obama for the coming week and delved into new material.
Several clergy members who pray, e-mail and talk with the president also assembled, as they often do, to offer advice by messaging and speaking with Dubois.
Obama moved between biblical teachings from the life of Job and verses of Psalm 46 in what amounted to a personal search for the appropriate message, aides and advisors said, and merged his speechwriters with his spiritual counselors in an unusual collaboration.
It wasn't the first time Obama has meditated on the life of Job, the biblical figure who loses his family, health and money. Like a tree that is cut down, the president told New Orleans residents on the anniversary of Hurricane Katrina, their city can sprout again.
This time, Obama was focusing on the sorrow of Job. Among the words read by the president, according to his aides: "When I looked for light, then came darkness." And: "Days of suffering confront me."
On Saturday and Sunday, he spent long stretches preparing for and then calling family members of those killed and injured in the shooting.
He also talked to Mark Kelly as Kelly sat by the bedside of his wife, Giffords, target of the apparent assassination attempt.
On Monday morning, the president's interim chief of staff, Pete Rouse, e-mailed the West Wing staff, notifying them that Ashley Turton had died that morning. She was pulling out of her garage on her way to work when she struck the building. Fire officials surmised the low-speed crash may have ignited flammable chemicals in the garage.
There was a brief break from work at the White House that morning when the staff spilled onto the frigid South Lawn, joining the president and Michelle Obama in a moment of silence to honor the Tucson shooting victims. Some said they also were thinking of the Turtons.
It was a moment to "connect in grief," said one staffer, with one another and with the Obamas.
Then they returned to their duties, focusing on the midweek memorial set for the University of Arizona sports arena.
Expectations for the president were high. The shooting had set off a national debate about political rhetoric. Political commentators were talking about the presidential moments of Ronald Reagan after the 1986 space shuttle Challenger explosion and George W. Bush after the Sept. 11, 2001, terrorist attacks. Would Obama be up to this moment?
The speechwriting started Monday. Obama summoned Cody Keenan, whose many written remarks for the president include his eulogy for Sen. Edward Kennedy, D-Mass. Keenan listened and wrote as the president dictated what he wanted to say.
Then there was research to do, such as tracking down "Faces of Hope," a book picturing 50 babies born on Sept. 11, 2001. One was Christina-Taylor Green, the third-grader who was killed when she went to the grocery store to meet Giffords.
In the book next to Christina's picture are aspirations for the children of Sept. 11. "I hope you know all the words to the National Anthem and sing it with your hand over your heart," it reads. "I hope you jump in rain puddles."
At the time of her death, Christina, 9, was almost the same age as Barack and Michelle Obama's younger daughter, Sasha.
Meanwhile, the president was moving his focus from the Book of Job toward Psalm 46, a familiar funeral text about how God is "our refuge and strength, an ever-present help in trouble."
The president and Keenan were going back and forth with DuBois, by e-mail and in conversations, in a search for the right verses.
In e-mails with the White House, religious advisors alluded to the psalm. Its familiar closing words speak of a divine fortress "exalted among nations."
But in the end, Obama settled on the lesser-noticed, middle part of the psalm: "There is a river whose streams make glad the city of God," it says in a passage he quoted at the start of his speech. "God will help her at break of day."
"The middle part is about heaven," said Joel Hunter, a Florida pastor who prepared one of the devotionals the president studied in the aftermath of the shootings. "That is exactly where we needed to go as a people ... to know that God is not only waiting for us but in our midst now."
Finally, the two images of water - the stream and the rain puddles - came together in the dramatic close of the speech.
"If there are rain puddles in heaven," Obama said, "Christina is jumping in them today. And here on this Earth, we place our hands over our hearts, and we commit ourselves as Americans to forging a country that is forever worthy of her gentle, happy spirit."
Presidential historian Doris Kearns Goodwin was struck by Obama's unusual show of emotion. As he spoke of Christina, his voice grew choked and hoarse for a moment. Throughout the speech, his face registered grief at some points, resolve at others and, as he announced that Giffords had opened her eyes for the first time, joy.
"He did exactly what the moment called for, in a way that was consistent with him as a cerebral president," Kearns Goodwin said. "It was a completely authentic moment."
There were critics of the memorial, especially of its pep rally quality as the crowd cheered the speakers. But for the most part, Obama did not play into it.
"We've seen the cognitive Obama and the executive Obama and the orator Obama," said the Rev. Samuel Rodriguez, an evangelical pastor who has conferred in the past with the president and his staff. "For the first time in his presidency, we have seen and felt the heart of Obama. And that was an important moment."
On Friday, the White House was still mourning. Obama spoke at the Holbrooke memorial while at the same hour aides and friends gathered for the funeral of Ashley Turton.