"The difference in X between Y and Z" -?

Solution 1:

"The difference in intelligence between a donkey and a mule"

I can't see a problem with this. "in intelligence" is effectively parenthetical.

"The difference (in intelligence) between a donkey and a mule"

Similarly we could invert it and get:

"The difference between a donkey and a mule, in intelligence, is considerable.

For me in this context "in" means "apropos".