Buhari's plane landed at the presidential wing of the Nnamdi Azikiwe International Airport in Abuja, the capital, late in the afternoon.
The 74-year-old President has not made any public appearances during this period or addressed the country directly apart from a short voice message to wish Muslims a happy Ramadan. He was expected to speak to Nigerians in a broadcast on Monday.
Vice President Yemi Osinbajo has been the acting President in his absence.
Buhari has been battling an unspecified illness since the beginning of the year and has spent long periods in London receiving treatment.
He first traveled to Britain for treatment from January to March, and then left Nigeria again on May 7.
His absence prompted intense speculation in the country about the President's health and many false reports circulated online saying he had died.
Buhari's aides released pictures showing him having lunch with senior members of his ruling party, All Progressives Congress (APC), in July to reassure Nigerians he is very much alive.
During his first medical leave, Buhari spoke on the phone with US President Donald Trump
and discussed combating terrorism, trade relations and other issues, according to aides. Many of the country's leaders, as well as the Archbishop of Canterbury, Justin Welby, visited Buhari at his Abuja House residence in London.
Last week, Buhari said he was feeling well enough to go back to Nigeria and was just awaiting his doctors' permission.
Buhari was elected President of Nigeria, Africa's largest economy and top oil producer, in 2015.
The former general became President in his fourth attempt at leadership since he was ousted from power in 1985.
Buhari was among military strongmen who dominated Nigeria decades ago. A military coup brought him to power in 1983, and another military coup toppled him two years later.
He's not the first Nigerian leader to leave the country during his tenure. In 2010, former President Umaru Yar'Adua was absent for three months as he received treatment in Saudi Arabia for inflammation of tissue around the heart. He died a few months after his return.
Unlike Buhari's absence, the absence of Yar'Adua created a power vacuum in Africa's most populous nation. It also sparked demonstrations in Abuja, where protesters demanded a constitutional order on his absence and evidence about his true state of health.
Africa's largest economy
As Buhari comes back home, he will face a troubled economy.
Nigeria exports plenty of oil, but it relies on shipments from abroad to source basic household items and food.
The exchange rate for the country's currency -- the naira -- has also fluctuated significantly this year, pressured by collapsing oil prices.
Nigeria's oil exports plunged in 2016. The government struggled to deter attacks on pipelines and barges in the Niger Delta that help move oil supplies out of the country, but it has since recovered some lost ground.