The integral $\int_a^b fdg$ of real or complex-valued functions of unbounded variation on a finite interval $(a,b)$ is defined using composition formulas and integration-by-parts rules for fractional integrals and Weyl derivatives. This integral is defined as $$ \int_a^b fdg=(-1)^\alpha \int_a^b D^\alpha_{a+} [f(x)-f(a+)]D^{1-\alpha}_{b-}[g(x)-g(b-)]dx+f(a+)(g(b-)-g(a+)),$$ where $f$ and $g$ satisfy some fractional differentiability conditions in $L_p$-spaces, and $\alpha\in [0,1]$. If $g$ has bounded variation and $f$ is bounded and right- (or left-)continuous at $dg$-almost all points (or satisfies a suitable integrability condition), then this integral coincides with the classical Lebesgue-Stieltjes integral. In the special case of Hölder continuous functions $f$ and $g$ of summed order greater than 1 then the convergence of the Riemann-Stieltjes sums to the integral is proved. Furthermore, the integral as a function of the boundary is Hölder continuous of the same order as $g$. The paper contains some applications of the above results to stochastic calculus, obtained by replacing $g$ by the trajectories of a Brownian motion $W$. First it is proved that for adapted random $L_2$-functions $f$ of fractional degree of differentiability greater than $1/2$ the integral exists and coincides with the classical Itô integral with probability one. For the more general class of adapted functions having fractional derivatives of all orders less than 1/2, the author proves an approximation result for the Itô integral by the integrals of a regularization of $f$. These results are extended to anticipating random functions $f$ by means of the Wiener chaos expansion. In this case the integral defined in this paper is related with the forward integral, which can be expressed in terms of the Skorokhod integral and a complementary term involving the derivative operator [see {\it D. Nualart} and {\it E. Pardoux}, Probab. Theory Relat. Fields 78, No. 4, 535-581 (1988;

Zbl 0629.60061)]. The application to pathwise defined stochastic integrals with respect to fractional Brownian motion is also discussed.