Existence: For every $\hat{z} \in \hat{X}$ pick a curve $\hat{\gamma}$ in $\hat{X}$ from $\hat{x}$ to $\hat{z}$, that is $\hat{\gamma} (0) = \hat{x}$, and $\hat{\gamma} (1) = \hat{z}$, and let $\gamma = p \circ \hat{\gamma}$. Let $\hat{\Gamma}$ be the unique lift of $f \circ \gamma$ in $Y$ to $\hat{Y}$ starting at $\hat{y}$. Define $\hat{f}(\hat{z}) = \hat{\Gamma} (1)$. It's easy to see, that this does not depend on the choice of $\hat{\gamma}$, because if $\tilde{\gamma}$ is another such curve, then they are homotopic (while the endpoints are fixed), because $\hat{X}$ is simply-connected, thus $f \circ p \circ \hat{\gamma}$ is homotopic to $f \circ p \circ \tilde{\gamma}$ (while the endpoints are fixed). Thus their unique lifts to $\hat{Y}$ starting at $\hat{y}$ has the same endpoints too (due to the properties of the lifts).
Uniqueness: Let $\hat{z} \in \hat{X}$, and $\hat{f}'$ another function satisfying the conditions. Pick again any curve $\hat{\gamma}'$ in $\hat{X}$ from $\hat{x}$ to $\hat{z}$. Now $\hat{f}' \circ \hat{\gamma}' = \hat{\Gamma}'$ is a curve like $\hat{\Gamma}$ was in the Existence part, thus $\hat{f}' (\hat{z}) = \hat{f}' (\hat{\gamma}'(1)) = \hat{\Gamma}' (1) = \hat{f} (\hat{z})$, thus $\hat{f}' = \hat{f}$.