Resident doctors - who used to be called junior doctors - make up about 42% of all Scotland's doctors and range from newly qualified doctors to those with 10 years or more experience.
Members will now consider an offer of a 4.25% pay rise in 2025-26, followed by a 3.75% increase in 2026-27.
The pay deal offered by the Scottish government matches one already accepted by nurses and other healthcare staff, and was previously rejected by the BMA last year.
However it now comes alongside a separate package of contractual reform.
The offer would see the basic pay for a newly qualified doctor rise from £34,500 to £37,345 for 2026/27 and for a doctor with 10 years experience rise from £71,549 to £77,387.
Gray said the deal had been struck following "days of intensive and constructive talks" between the government and the union.
He added that total investment in the offer - covering both pay and contract reform over the two-year period - will be £133m.
He said: "This avoids the cancelled operations and disruption to patient care that no one, including resident doctors, wanted to see."