# nminimize or findminimum with findroot

I have a problem with form similar to the following:

I have a set of equations that is f(x, y) = 0. For each x, I can use FindRoot to find a value of y. Suppose I want to select the x such that the implied value of y is minimises something like (y- y*)^2.

I feel like I want to combine NMinimize or FindMinimum with FindRoot but have difficulty achieving this.

Without information about y* you could solve your problem in one step using NMinimize:
NMinimize[{(y-ystar)^2,f[x,y]==0},{x,y}]