Health Secretary Humza Yousaf said the award "demonstrates that we value all our medical and dental staff and the important contribution they make".
However, BMA Scotland chairman Dr Lewis Morrison described it as a "large real-terms pay cut" in the face of spiralling inflation.
Eligible doctors and dentists in England will get a similar pay rise.
The pay award in Scotland will be backdated to 1 April.
It follows the recommendation of the independent Doctors and Dentists Pay Review Body (DDRB), which the Scottish government accepted.
Mr Yousaf said staff had worked tirelessly to provide care while under increased pressure as a result of the pandemic.
"This uplift demonstrates that we value all our medical and dental staff and the important contribution they make," he added.
"It's crucial that we continue to not only recruit and build our future NHS workforce, but also retain expertise within NHS Scotland.
"This announcement means that our senior medical staff will continue to be the best paid in the UK. This will help ensure that NHS Scotland remains an attractive employment option for all medical and dental staff."
The government said the award built on last year's 3% pay rise, meaning staff have had a 7.5% pay increase over two years.
However prices are rising faster than they have done for 40 years and inflation increased to 9.1% in the 12 months to May, according to the Office for National Statistics.
The Bank of England has predicted that inflation could reach more than 11% later this year.
BMA Scotland said the deal did "nothing to undo years of real-term pay erosion for doctors".
Chairman Dr Lewis Morrison added: "The Scottish government has to reflect on how it really values and treats our medical workforce, if it genuinely wants to ensure NHS recovery and a future of healthcare in Scotland that will meet the needs of its people," he said.
"In response to this hugely disappointing award we will be urgently consulting our members to gauge their views, and what steps we may take as a result."
He added: "In the face of spiralling inflation this is still a large real-terms pay cut, which will be hugely damaging to the morale of an already exhausted and depleted workforce, after two-and-a-half-years leading our country's response to the pandemic and the years of vacancies and escalating demand that preceded that."
About 160,000 other NHS staff, including nurses, paramedics and healthcare support staff, are being balloted of a 5% pay offer.
It came as the UK government announced pay rises for public sector workers. mainly in England and Wales.
It included a £1,900 salary uplift for police officers south of the border.
Police Scotland officers have withdrawn "all goodwill" after being offered a £565 pay rise described as "derisory" by the Scottish Police Federation.
Its general secretary, Calum Steele, said a formal revised offer was due to be discussed on Wednesday but it was likely to be rejected as it was lower than the award for England and Wales.
Meanwhile all members of the armed forces - of which there are about 10,000 in Scotland - will receive an increase in basic pay of 3.75%.