when there is a potential difference it means that there is a flow of electrons from one terminal to the other. any 2 electrons seperated by a distance generate an electron cloud or electric charge space around them which is treated as electric field.
also electric field is defined as electric potential per unit distance. so on integrating the complete electric field over the length, we can get the electric potential.