When President Obama delivered the keynote address to the Democratic National Convention in 2004, he borrowed a pale blue tie from his press secretary Robert Gibbs, who has since gained a reputation for his love of pastel-colored neckwear.

On Friday, Mr. Gibbs’s last day on the job, Mr. Obama surprised the press secretary by giving the tie back — framed under glass, with some photographs and a note.

“He has not said anything about this tie all these years, but I have to tell you that I know there’s a simmering resentment that he never got the tie back,’’ Mr. Obama joked, before Mr. Gibbs’ took his final round of questions from reporters in the White House briefing room. He added, “I wanted this on record, on camera, that I’m finally returning Robert’s tie, and if he chooses to break the glass, he can.’’

Mr. Obama appeared in the briefing room shortly after he delivered his formal statement on the departure of President Hosni Mubarak in Egypt, and he left without taking any questions on the situation there. But he did refer to it at the outset of his remarks.

“Obviously,’’ the president said, “Gibbs’s departure is not the biggest one today.’’