The vote staged by the Rail Maritime and Transport union (RMT) produced a majority for strikes and other action, but it was not large enough to enable any stoppages to go ahead.
It followed workers being told they would not get a pay increase this year because of the huge extra cost of keeping ScotRail going during the pandemic when passenger numbers have fallen by more than 80 per cent.
But the RMT pointed to drivers benefiting from an increase this year after their union Aslef won a two-year deal in 2019.
Union members voted by 756 to 631 for strike action and 955 to 432 for action short of strikes.
RMT general secretary Mick Cash said: “While this is a positive result with a clear majority favouring the union's position of taking strike action and action short of strike, the prohibitive anti-union laws requiring 40 per cent of those entitled to vote to vote Yes has not been reached.
"Because the 40 per cent threshold has not been met, we are unable to use the mandate you have given us.”
The union blamed ScotRail tactics for the ballot result.
An RMT spokesperson said: "This result reflects the fact that ScotRail threw unprecedented levels of resources at a campaign of misinformation and intimidation designed to influence the outcome.
"Regardless of all of that, we recorded a clear yes vote for action but we are banned from acting as there is one form of democracy for politicians and another for trade unionists.
"A combination of threats, propaganda and the Tory anti-union laws have been mixed together into a toxic cocktail targeted at individuals with the sole intention of putting the frighteners on.
"It's a tribute to our members that they stood firm and voted for action in the teeth of such a hostile and aggressive campaign by ScotRail.
"RMT's campaign for pay justice for the transport staff who have kept Britain and its essential workers moving throughout the Covid pandemic will continue regardless."
ScotRail said only 31 per cent of those balloted had backed strike action.
It said: “ScotRail’s credibility with passengers and the taxpayer would be damaged by any strike action during a national crisis”.
The train operator said it had urged staff not to strike because the Scottish Government had to give permission for pay talks as a condition of its extra Covid support, which had not been granted.
It also stressed that no permanent jobs have been lost or furloughed and there had been no changes to basic salary levels, in stark contrast to other businesses, including other transport providers, where thousands of jobs had been lost.
Chief operating officer Alex White said: “I am glad ScotRail staff decided not to support strike action.
"While this is an issue that has led to a lot of discussion across our organisation, I welcome the decision that has been reached as I feel that it is right for the railway and our passengers.
“Strike action at a time of national crisis, and when we benefit from a level of job security not enjoyed by other industries, would have been wrong.”