This year's pay rise will be back-dated to April.
The deal was reached in September but Scotland's largest teaching union, the EIS, sought approval from its members before accepting the offer.
It also includes a written commitment on attempting to manage teachers' workload.
Education secretary Angela Constance said: "Reaching this agreement on a pay increase demonstrates the benefit of government, employers and unions working together positively, particularly in the current challenging financial climate."
EIS salaries convener Tom Tracey said: "In a difficult financial context this deal was the best that could be achieved through negotiation.
"We are aware that teachers in England have no right to salary progression and have pay linked to performance.
"This offer exceeds the pay policy that is applied by the Westminster government and while teachers in Scotland continue to pay the price of austerity, a modest pay uplift is welcome at this time."
Teachers are employed by councils but pay and conditions are agreed nationally.
The offer also covers teachers employed by councils, including Glasgow, which are no longer members of the council umbrella body Cosla.
A two-year deal which will see Scottish teachers get a 1.5% pay rise this year and a 1% rise in 2016 has been formally agreed.