President Obama talks with Earl Smith in the Oval Office on Jan. 22, 2013. (Pete Souza/THE WHITE HOUSE)

Five years ago, there had been a chance encounter in an Austin elevator between a Vietnam veteran and a future commander in chief. For the rest of the campaign, the candidate would carry the military patch that the stranger gave him that day.

On Tuesday, Earl Smith met Barack Obama again — this time, in the Oval Office.

The 68-year-old former infantryman gave the president a salute, and Obama returned it.

Over the years, the gift of that military patch had taken on an almost mythic significance among the Obama inner circle.

Obama carried it among about a dozen similar tokens that people had pressed upon him during the 2008 campaign, and he told aides that it was a reminder of why he had run for president in the first place.

When Earl Smith first met then Senator Obama in an elevator in February 2008 at the Hyatt Regency in Austin, his time with the future President was short. But Smith gave Obama something that he would carry with him for the rest of the campaign. (Jayne Orenstein/The Washington Post)

His top adviser Valerie Jarrett would frequently mention it in commencement addresses as a symbol of the hopes that ordinary Americans have in their president.

But they were never aware of the man’s name — much less the story of resilience that was woven into his military patch — until The Washington Post uncovered it.

Smith, who is director of security at the Hyatt Regency in the Texas capital, was also astonished to learn of the impression he had made on Obama.

Once the Obama team learned his identity, Smith was invited to attend the president’s swearing-in Monday. He was featured in an Inauguration Day segment on the “Today” show.

And on the day after that, he was invited to meet Obama again.

Jarrett and Eric Whitaker, Obama friends who had also been aboard the elevator that day, joined them in the Oval Office.

“They talked about their meeting, and the president said to Earl how much it had meant to him at the time, and how he enjoyed reading [The Washington Post] story about Earl,” Jarrett said. “He said to Earl, ‘I learned more about you, and my respect for you grew.’ ”

He had served in Vietnam in a unit that suffered 10,041 casualties over the course of the war. From the time he had come home, the patch — which was the only shred he kept of his uniform — had been Smith’s lucky charm. Smith had survived the war, and endured three years in prison in the 1970s on charges for which he was later pardoned. He then built a successful career in the hotel industry, which took him and his patch halfway around the world again.

Smith asked the president to autograph a paperback copy of Obama’s autobiography, “Dreams From My Father.” Obama did, and added a personal note.

Jarrett gave Smith bound copies of several speeches in which she had invoked his story.

In an interview before his meeting with Obama, Smith said the whole experience had been remarkable. But the moment that stuck with him was the one that came at the end of the inauguration, when Obama turned back to take one more look at the crowd — a throng that included the man who had given him the patch.

“It just felt so good when he did that,” Smith said.