Both leaders met Sunday in Addis Ababa, Ethiopia, at the opening session of the 30th African Union Summit.
They both shook hands and talked for about two minutes.
Their brief contact became a sensation inside the Nelson Mandela Hall as photojournalists made frantic efforts to capture the moment.
A former head of state, General Abdulsalami Abubakar, later joined Buhari and Obasanjo for a photograph.
Obasanjo had advised Buhari to consider a deserved rest at his age after his first term.