Bobby Clifford, 22, and Toby Clarke, 22, were among a group of a dozen men who had been watching England's World Cup semi-final defeat to Croatia in July last year.
British Transport Police heard the pair were part of a large group who had travelled from Chippenham to Bath on July 11 last year to watch the game.
On the return journey home, the group was behaving rowdily at Bath Spa station, with one of the group, Dominic Patten, throwing a bin lid and his beer can on the track.
They boarded the 10.26pm train and were seen to be drinking heavily, having loud sexually explicit conversations and crawling in the overhead carriage.
A female passenger who challenged their behaviour was met with a torrent of abusive language.
The incident, which lasted a period of around 20 minutes, culminated in Clarke pulling down his trousers and defecating in a takeaway box in view of other passengers.
Clifford then picked up the box containing the faeces and threw it down the carriage, causing some of the contents to land on a traumatised passenger.
Most of the group then alighted the train at Chippenham, leaving passengers horrified by the incident.
Inspector Scott Hargreave, of British Transport Police, said: "The individuals involved in this incident are very fortunate that they aren't facing an immediate custodial sentence - their actions and behaviours were reprehensible.
"I would like to reassure the travelling public that incidents like this are rare - any incident of which we are made aware of, we will police and investigate robustly.
"I hope this sends a clear warning to everyone that this type of disgusting behaviour will not be tolerated on the railway, and these offenders will be brought before the courts."
Clifford, St Peters Close, Chippenham, was sentenced to six months' imprisonment, suspended for a year, and was also ordered to complete 10 rehabilitation activity days and 100 hours of unpaid work.
The judge also told him to pay £1,000 to the victim who was hit with the faeces, £100 to each of the three witnesses and £510 in costs.
Clarke, of Whaddon, Hilperton, Wiltshire, was sentenced to a 12-month community order with a requirement to complete 280 hours of unpaid work. He must pay £400 compensation to each of the witnesses and £510 costs.
Patten, 22, of Chippenham, previously admitted two counts of battery and one count of endangering the safety of a person conveyed on a railway and was sentenced to a three-month curfew.