You should use double-quotes "
to surround files, folders or variables that contain special characters or whitespace.
From the example you provided, that would be as follows:
~$ mkdir "temp space"~$ temp=$(echo "temp space")~$ echo "$temp"temp space~$ cd "$temp"temp space$