Preston North End scored three at Deepdale as Cardiff City's unbeaten start to the 2017/18 campaign came to a close.
Neil Warnock named an unchanged side after Saturday’s 1-1 draw against Fulham, with City lining up in their away kit for the first time.
Preston had the first opportunity of the game shortly after the opening minute. However, Neil Etheridge made a fine low save to deny the hosts an early lead at Deepdale.
Kenneth Zohore had Cardiff’s first real chance of the match in the 18th minute, but the forward fired over the bar from just outside the penalty area.
The Lilywhites continued to press the City defence, but the Bluebirds remained resilient at the back until they created more opportunities to get forward. Joe Bennett had a shot blocked before Ralls’ close effort deflected wide for a corner.
However, in the 37th minute the home side had the advantage as Manchester United loanee Joshua Harrop scored directly from a free kick. The ball found the bottom right corner of Etheridge’s goal from 25 yards.
Cardiff restarted the game after the break and looked brighter at the start of the second period.
But with 20 minutes left, Sean Maguire extended the lead for Alex Neil’s men. The forward squeezed in an angled shot from inside the Bluebirds' penalty area to make it 2-0 on the night.
In the 78th minute, the home side made it three. Etheridge cleared the ball as far as Alan Browne, who managed to find the back of the net in spectacular fashion from 45 yards.
After five minutes of added time, the referee blew his whistle as City were defeated in the league for the first time this season.