Yes. A function f: A -> B is injective (or an injection) when two function values being equal implies that they are the image of the same point.
That is: for all a, b in A: f(a) = f(b) implies a = b.
Why this is a necessary condition is easy to see. Suppose that you have two values a, b that are different, but f(a) = f(b) = y. Now, you are writing down the inverse function f-1... what value do you assign for f-1(y)? It should be both a and b, because f(a) = y and f(b) = y, but f-1(y) can only have one value.
It is also a sufficient condition: after all, all you need to define an inverse function is to say for every y in B, which x in A to map it to such that f(x) = y again.
If it is not clear, think about f(x) = x2. If you only define the function for x > 0 (you can include 0 if you like) then there is no problem to write down the inverse function: f-1(y) = sqrt(y). But if you define f(x) for all x (also negative numbers) it is no longer injective. Indeed, -2 and 2 are completely different numbers, but f(-2) = f(2) = 4. So you cannot consistently assign a value for f-1(4), and always get f(f-1(x)) = x.