The Communication Workers Union said 46,391 workers (49.1%) voted in favour of industrial action and 48,038 (50.9%) voted against.
The result will come as a surprise to the union, which had been expecting a big vote in favour of strikes, scheduled to start later this month.
It has been pressing for an upfront payment of 8% after rejecting the Royal Mail's offer of 14.5%, linked to productivity improvements.
The CWU complained that the offer contained "more strings than the philharmonic orchestra" and said it was determined to achieve a basic minimum of £300 a week for its Royal Mail members
The Royal Mail, which is losing £750,000 a day, warned that strikes would be "commercial suicide", costing the business around £20m a day.
The last national strike was in 1996 when mail deliveries were crippled by a series of stoppages over pay.