Mayor Marion Barry and Councilman John A. Wilson reached a compromise on a critical item in the District's 1982 budget yesterday, averting the threat of a mayoral veto of a major amendment imposed by the City Council, Wilson said last night.

They agreed to restore $10 million of a $20 million fund the mayor wanted set up to repay loans he hopes to negotiate during the current year. The other $10 milliion will be left in a kitty earmarked to give salary raises to city workers next year. The mayor's original budget contained no funds for salary increases.

Barry could not be reached for comment last night. Wilson said that if the procedural problems of changing a budget on which final action has been taken could be worked out, "It would satisfy me. I'm interested in working together, not in winning or losing battles with the mayor." Wilson said he had offered the same compromise before the key vote was taken but the mayor had refused it, thinking he had the votes to defeat it.

On Wednesday, Wilson, chairman of the council's Finance and Revenue Committee, spearheaded a move in the council to divert the Mayor's proposed $20 million fund -- which Barry regarded as essential to his plan to pay off the city's cumulative $409 million deficit -- into salary increases for city workers. Wilson argued that the loans, which the $20 million would begin to repay, were unlikely to be made, and since pay increases will surely be required, it was essential to have some money for them.

Barry immediately threatened to veto the transfer, but it was questionable whether he had the votes on the council to sustain a veto.

The reported compromise would help the mayor sustain the basic principle of his long-range financial rescue program, which is that the city should borrow $215 million this year from the U.S. Treasury to meet "immediate cash needs" and pay of the rest of the deficit with appropriations out of tax revenues in later years. If the entire $20 million had been deleted, as the council voted to do on Wednesday, he could not obtained the loans because he would not have had any funds to begin repaying them.

The Kitty of funds for a pay increase was reduced by the reported compromise to $16.8 million. That is far below the amount that Wilson and the mayor agree will probably be needed when a contract is negotiated with the workers, but no other source of funds is currently available.