The Tobacco and Primary Medical Services Bill was passed on Wednesday by 108 votes to 15.
It amends the 1978 NHS Act by removing the ability for commercial companies to hold primary medical services contracts.
The BMA said the move will ensure ‘continuity of care of patients' and ensure that general practice ‘remains the cornerstone of the NHS'.
Dr Dean Marshall, chairman of the GPC in Scotland, suggested the government must now work with primary healthcare professionals to make sure that the service is the best it can be.
He said: 'Doctors across Scotland welcome this commitment to a publicly provided and delivered NHS.
'Accountability to a commercial employer and short-term contracts are an uncertain basis for the long-term relationship between professionals and patients upon which effective primary care depends.'