A High Court dismissed Winnie Madikizela-Mandela's application and ordered her to pay all legal costs.
She argued that the house in Qunu village belonged to her under customary law.
Mr Mandela, who became South Africa's first black president in 1994, bequeathed the property to his family when he died in 2013 aged 95.
The government opposed Ms Madikizela-Mandela's bid to inherit the home after she launched court action in 2014.
Mr Mandela divorced Ms Madikizela-Mandela in 1996 after a 38-year marriage, and left her out of his will.
They were South Africa's most celebrated political couple until their marriage collapsed unexpectedly, some six years after his release from 27 years in prison for fighting apartheid, which legalised discrimination against black people in the country.
Mr Mandela stepped down as president after one term in 1999.
South Africans regarded him as the "father of the nation", and his death, following a series of hospital visits, led to an outpouring of emotions.
Nelson Mandela's ex-wife has lost her legal bid for ownership of the former president's rural home in South Africa.