Photos and a video posted on Twitter showed Mr Buhari, 74, attending Friday prayers at a mosque in the presidential villa in the capital Abuja.
The footage showed the president shaking hands with fellow worshippers.
Aides say Mr Buhari has been resting after receiving medical treatment in London for an undisclosed illness.
Earlier this week, the president missed his third cabinet meeting in a row, stoking further debate about his condition. Until Friday, he had not been seen in public for two weeks.
Mr Buhari returned from the UK in March after seven weeks of sick leave. When he returned home he said he had never been so ill in his life.
Since then he has rarely been seen outside of his official residence. His wife, Aisha, has said that her husband is not as sick as is being perceived.
Correspondents say a power vacuum in Nigeria, or even the perception of it, could have damaging effects.
The country is at a crucial stage as it struggles to emerge from recession.
Last week, presidential spokesman Garba Shehu said Mr Buhari was “taking things slowly, as he fully recovers from the long period of treatment”.