Scotland's Justice Secretary said he would "encourage" the armed forces to formally pardon men convicted of discriminatory historic sexual offences and disregard these convictions.
Michael Matheson said it would be "difficult" for the Ministry of Defence (MoD) to refuse to take action on men who were criminalised under military rules given UK and Scottish legislation.
He said the armed forces should take steps to "correct" the records of those who were discharged for being gay.
Mr Matheson was giving evidence to Holyrood's Equalities and Human Rights Committee on the Historical Sexual Offences (Pardons and Disregards) Bill which will provide an automatic pardon to men in Scotland convicted of such offences and enable them to apply for the convictions to be struck off their criminal record, known as a disregard.
The committee has written to the MoD seeking the organisation's views on the issue.
Mr Matheson said: "There is an opportunity here for the Ministry of Defence to recognise that as wider society is righting a wrong, there is an opportunity for the military to right a wrong as well and to look at their existing military rules, previous military rules that applied in this area and the way in which they were discriminatory in nature against individuals within the armed forces."
He added: "To be frank, it must be difficult for the MoD to come back and say, 'no I don't think we should do anything'.
"If we have a scheme in England and Wales and we are about to introduce a scheme here in Scotland, which has got cross-party support, I think it would be difficult for the MoD to say anything other than 'we are going to look at this and try and find a mechanism which allows us to introduce a disregards scheme or a pardons scheme about how their military rules operate'.
"I would certainly want to encourage them to do so."
Mr Matheson said in the past some people were discharged from the armed forces for being gay without having any criminal conviction, which would remain on their military record.
He added: "It would seem reasonable to me that the military should be looking to correct that, in the same way in which we are seeking to do that through our own criminal justice system."
He offered to make Scottish Government representations to the MoD once the committee receives a reply.
Conservative Jamie Greene said anecdotal discussions with armed forces have been "very positive" of a cultural shift on the issue.
Introducing the proposed pardons and disregards bill to parliament last year, First Minister Nicola Sturgeon apologised for what she said were "completely unjust" laws.