Melbourne's trains will stop for four hours later this month as the public transport union escalates its fight against Metro Trains for better pay.

Train drivers, customer service personnel and station staff will walk off the job between 10am and 2pm on Tuesday, August 27.

The strike was announced within hours of Metro taking an 11th-hour injunction to the Federal Court on Friday morning in a bid to force workers to keep ticket barriers shut on the next two Mondays.

Justice John Snaden ruled in favour of the injunction, which means that commuters will have to touch their myki cards on and off.

Rail, Tram and Bus Union state secretary Luba Grigorovitch denied the strike was a response to the injunction, arguing that it was instead a reaction to Metro's decision to dock the pay of workers engaging in work bans from next week.