An excerpt from Mac Lane's Categories for the Working Mathematician (p29, Notes on Chapter 1):
The fundamental idea of representing a function by an arrow first appeared in topology about 1940, probably in papers or lectures by W. Hurewicz on relative homotopy groups; see [1941].
His initiative immediately attracted the attention of R.H. Fox (see Fox [1943]) and N.E. Steenrod, whose [1941] paper used arrows and (implicitly) functors; see also Hurewicz-Steenrod [1941]. The arrow $f: X\to Y$ rapidly displaced the occasional notation $f(X)\subset Y$ for a function. It expressed well a central interest of topology. Thus a notation (the arrow) led to a concept (category).
Commutative diagrams were probably also first used by Hurewicz.
Categories, functors and natural transformations themselves were discovered by Eilenberg-Mac Lane [1942a] in their study of limits (via natural transformations) for universal coefficient theorems for Čech cohomology. In this paper commutative diagrams appeared in print (probably for the first time). Thus $\mathrm{Ext}$ was one of the first functors considered. A direct treatment of categories in their own right appeared in Eilenberg-Mac Lane [1945].
This last mentioned paper is the one referred to in KConrad's answer.