Andrew Stoddart was due to quit his holding on November 28, but following talks with Scottish Government ministers, his landlords the Colstoun Trust agreed the family would be able to remain in the farm cottage after the end of the tenancy.
They will also be able to use the grazing land and farm buildings at Colstoun Mains Farm, Haddington.
The terms of the settlement are subject to a confidentiality agreement, but it is understood the offer is confirmed until the end of January.
Mr Stoddart is one of eight farmers who have been affected by ‘defective’ legislation which was rushed through Scottish Parliament in 2003.
It was designed to allow any limited partnership (LP) tenant farmers facing early eviction to ‘upgrade’ to secure tenant status.
However, the legislation was proved unlawful in 2013, meaning those tenants who thought they could continue their tenancies, could not.
In a statement, the beef and sheep farmer said: “After 22 years, against considerable odds, I have left this farm better than I found it. It has been a hard struggle at times, and I want to pay tribute to my wife Claire who has shared the burden with me. We probably should have left many years ago when difficulties with the landlords began, but we never suspected it would end like this.
“We thought the 2003 Act had changed our lives, only to see our hopes dashed by the remedial order of 2014. The laws which allow landlords to arbitrarily end tenancies in order to access farming subsidies directly need amending.”
The Scottish Tenant Farmers Association (STFA) which has been campaigning on behalf of Mr Stoddart, thanked Scottish Government ministers who brokered the deal.
STFA director Angus McCall added: “We hope lessons will be learnt and the remaining seven tenants and families in the same situation will not be expected to suffer as much worry and stress as the Stoddarts.
“There are still a large number of tenants on short term agreements who are just as vulnerable to having their tenure cut short at the drop of a hat. This insecurity is something that must be tackled as Scotland contemplates land and tenancy reform over the next few years.”
Scottish Land and Estates chairman David Johnstone said it was ‘regrettable’ that Mr Stoddart was given false hope by defective legislation brought forward by the then Scottish Executive many years ago.
“Both landlords and tenants continue to be affected by the consequences and we would appeal for very careful consideration of complex agricultural legislation which forms part of the current Land Reform Bill,” Mr Johnstone added.