The UK government is to compensate thousands of soldiers who faced having to pay more income tax because they are based in Scotland.
Anyone earning more than about £26,000 in Scotland now pays more income tax than they would if they lived elsewhere in the UK.
The MoD says about 8,000 military personnel have been affected.
They will now be reimbursed with an annual payment to ensure all military staff pay the same tax.
Income tax rates and bands have been devolved to Holyrood, with the Scottish government using its new powers to introduce what it says is a more "progressive" taxation system than the three-band system in place elsewhere in the UK.
The new Scottish system adds a 19% "starter" rate for those on low incomes, as well as a 21% rate for those who earn above £24,000. It also adds a penny to the higher and top rates, bringing them to 41% and 46%.
The changes mean lower earners pay slightly less tax than those elsewhere in the UK, while middle and higher earners pay more.
The UK government has said the changes mean about 70% of its military personnel in Scotland are now facing higher bills than their colleagues elsewhere.
It argues this could make Scotland a "less attractive place for military personnel to be posted to", and could impact on recruitment and retention.
It has previously been estimated that a staff sergeant would pay about £117 a year more in Scotland, with a major paying about £660 more, a lieutenant colonel about £863 more and a full colonel an extra £1,013.
However, a private based in Scotland would pay about £20 a year less in income tax.
The MoD says personnel who have been affected by tax rises in Scotland will now be compensated with an annual payment to ensure no troops have to pay more because of where they are deployed or where their families are based.
It said its plan will see "mitigation payments" of between £12 and £1,500 paid to regular personnel who pay Scottish Income Tax, regardless of where in the world they are serving..
The MoD said the total cost for the current tax year is expected to be £4m, with the case for the payments being reviewed annually.
Defence Secretary Gavin Williamson said: "It is completely wrong for the brave men and women of our armed forces to be punished for serving in Scotland by unfair raids on their pay packets by the Scottish government.
"That's why we have taken this urgent action to ensure that our troops are treated equally and fairly."
The Scottish government said it had offered to discuss the issue with the UK government earlier this year but did not receive a reply.
Finance Secretary Derek Mackay said: "As a result of the Scottish government's progressive tax system 70% of people in Scotland are paying less tax this year than they did last year for a given income and we hope those who have seen their tax bills reduce will not be disadvantaged by the UK government's proposals.
"We are fully committed to supporting the armed forces community and armed forces families in Scotland benefit from services not available elsewhere in the UK, such as free school meals, prescriptions and eye tests, and tuition fee and living cost support in higher education when they are ordinarily resident.
"It is disappointing that, despite making an offer to discuss the differential taxation of military personnel, the Scottish government has not been consulted on the proposal announced by the MoD."