Prove that $f$ is one-to-one on $B$ and $f^{-1}:Y\to B$ is Borel.
This is a special case of some high-powered machinery in Descriptive Set Theory. I tried for a while to find an easier approach, but I was unable to.
Theorem: (cf. Theorem 6.3 here, or Section 5.2 of Srivastava's "A Course on Borel Sets")
Let $X$ and $Y$ be polish spaces, and $F : X \to 2^Y$ a function so that $F(x)$ is $\sigma$-compact for each $x$.
Suppose moreover that $\Gamma_F = \{ (x,y) ~|~ y \in F(x) \}$ is borel in $X \times Y$.
Then
- $\text{dom}(X) = \{x ~|~ F(x) \neq \emptyset \}$ is borel
- $F$ has a "borel selection function". That is, a borel function $f : \text{dom}(X) \to Y$ such that $f(x) \in F(x)$ for every $x$.
Then, in your case, we let $G : Y \to 2^X$ with $G(y) = f^{-1}(y)$. Since $X$ is compact, $f^{-1}(y)$ is compact too (in particular $\sigma$-compact). Moreover, $\Gamma_G$ is borel in $Y \times X$ since
$$\Gamma_G = \{(y,x) ~|~ x \in G(y) \} = \{(y,x) ~|~ x \in f^{-1}(y) \} = \{(y,x) ~|~ f(x) = y \}$$
and the graph of a borel function is a borel set.
So, proof by nuke, $\text{dom}(Y) = Y$ since $f$ was surjective, and the theorem guarantees a borel $g : Y \to X$ so that $g(y) \in G(y)$. That is, $g(y) \in f^{-1}(y)$. This is the required section.
I hope this helps ^_^