When we talked about the built-in barrier potential of a pn junction, perhaps you thought about measuring it on a disconnected diode in the lab. (Even if you didn’t think of it, you should go ahead and try it). You will find that it doesn’t work. It is worth thinking about why i.e. why can’t you measure the built-in potential of a pn junction with a simple voltmeter (or why do we need a special diode mode in a multimeter)?
At one level, it is easy to see why this can’t work: a bare diode cannot drive a current (that would be needed to measure a voltage in a voltmeter), because that would require the diode to supply power which would effectively make it a perpetual motion machine. (If you are unfamiliar with perpetual motion, treat yourself to a tour of the work of the Dutch artist M.C. Escher.)
But I don’t find this entirely satisfactory. In particular, we should still be able to show how, for instance, to explain the voltmeter measurement in terms of the Kirchoff voltage law. For some interesting discussions of this question see here and here. I find the below quote from this forum very appealing:
In a simple idealized view, the Fermi level is the top energy level in the solid occupied by electrons. In silicon with no doping it sits at mid-gap: the valance band is full, the conduction band empty. In a thought experiment, if you had two separate chunks of intrinsic silicon each would be perfectly happy in isolation. If you could mash them together to make a “junction”, everything would still be perfectly happy – the Fermi levels line up, and no electron has any real desire to do something else.
Adding dopants shifts the Fermi level. In n-doped material there are newly available occupied levels near the conduction band edge, and in p-doped materials there are newly available un-occupied levels near the valance band. By doping the material you have fixed the Fermi level at a new point. In isolation, the n-doped chunk is happy, and the p-doped chunk is happy. Here, though, when you mash them together to make the junction, they realize that together they aren’t happy. The occupied levels on the n-doped side are above empty levels in the p-doped side: this is a non-equilibrium condition since electron (hole) flow will reduce the energy of the system. But wait! Indeed, the electrons (holes) start sloshing around, but in doing so they leave behind the dopants. These now-abandoned dopants have a net charge, and an internal field begins to build up. It will build up until it is large enough to prevent further electron (hole) flow across the junction. However, an equivalent view is that this built in voltage is just what is needed to bring the different Fermi levels into alignment (as in @boyfarrell’s picture above). (I find the water analogy a bit misleading, since it is the separation of fixed dopants and moving charges that leads to the build-in voltage.)
So, ultimately, yes: the built-in voltage is precisely what makes the p-n junction in equilibrium with no net potential across the terminals.