Kazakhstan have won their United Cup tie against Spain after posting a tense victory in a mixed doubles encounter that was decided by a match tiebreak.