Rakitic undid a fine Wales first-half showing with a stunning strike just before the interval and substitute Gabric wrapped up victory late on.
Wales, denied the services of 15 senior players, could look back on their performance with pride and Simon Church was unlucky to have a goal disallowed.
Croatia had started well but Wales contributed to a first half which looked set to finish goalless until pressure eventually told as the hosts went ahead with a superb strike from Rakitic just before the break.
Croatia remained the dominant side in the second half but they did not make victory safe until the 82nd minute.
Modric cut open the Wales defence with a superb ball and Gabric raced clean through to fire low past Myhill.