Here is how you solve the problem if it is already assumed that $R$ has a unit:
Taking $b = 1$, a solution to $ax=1$ is a right inverse for each nonzero $a \in R$. Fix such a right inverse $ac=1$. Now $c$ also has a right inverse, $cd=1$. It follows that $a = a(cd) = (ac)d = d$, so $c$ is both a right and left inverse for $a$. This proves that every nonzero element of $R$ has a two-sided inverse.
For showing that $R$ has an identity:
What you have is, for each nonzero $a \in R$, an $e_a$ so that $a e_a = a$.
If $ab = 0$ for nonzero $a, b \in R$, then one can multiply on the right by the solution to $bx = e_a$ to get $0=abx = ae_a = a$, which is a contradiction. So $R$ has no zero divisors, which, as was noted in one of the comments, is equivalent to both left and right cancellation holding. So the $e_a$'s are unique for each fixed $a$.
As rschwieb's comment below suggests, you can use cancellation together with $a e_a e_a = a e_a$ to conclude that $e_a^2 = e_a$, making $e_a$ an idempotent. Then left canceling $e_a(e_a b - b) = 0$ makes $e_a$ a left unit for $R$, and right canceling $(b e_a - b) e_a = 0$ makes $e_a$ a right unit for $R$.
This is closely related to a standard trick for breaking down a ring given an idempotent: For $e \in R$ an idempotent in an arbitrary ring, we have $x = (x-ex) + (ex)$, which gives a direct sum decomposition of $R$ as a right module over itself.