Before you tell me there are a bunch of other similar questions asked as well, hear me out ;(
I'm really confused when it comes to work being done. When you're considering a charge moving from a one point to another against an electric field, you consider TWO types of work being done. One is the work being done by the external force (which is always positive, since cos0=1) and the other is the work being done by the electric field (which is always negative, since cos180=-1).
What I don't seem to understand is, whilst deriving the formula of potential gradient, why do we seem to mix up the work due to the electric field and work due to the external force? If we were to only consider work being done by the external force, technically, the formula for the potential gradient should be positive. But, in ALL the books, they seem to add in a negative sign by simply stating, "The negative sign indicates that the work being done is against the field force."
That should technically mean that they're considering work done due to the applied force, and according to the definition of work, it should be positive! But if you say just equate the external force to the electric force (since the external force is the negative of the electric force), then you'd also have to change cos0 to cos180 and thus, the negative sign would vanish again.
Which work do we consider? The one due to the external force or the one due to the electric field? Why? Is the negative sign just a convention to show us that we're actually considering the work due to the external force and that force acts in a direction opposite to the field force?
TL;DR: What is the mathematical explanation behind the origin of the negative sign (in terms of the cosine of the angles)? Where did it come from?
UPDATE: Philip's and Overwootch's answers give a pretty straight-forward mathematical explanation of where the negative sign popped up from, in case you were to traverse the charge in the direction of the electric field, or want to consider the work done by either the electric field or the electric force.