Numerical simulations and finite-size scaling analysis have been carried out to study the percolation behavior of straight rigid rods of length $k$ ($k$-mers) on two-dimensional square lattices. The $k$-mers, containing $k$ identical units (each one occupying a lattice site), were adsorbed at equilibrium on the lattice. The process was monitored by following the probability $R_{L,k}(theta)$ that a lattice composed of $L times L$ sites percolates at a concentration $theta$ of sites occupied by particles of size $k$. A nonmonotonic size dependence was observed for the percolation threshold, which decreases for small particles sizes, goes through a minimum, and finally asymptotically converges towards a definite value for large segments. This striking behavior has been interpreted as a consequence of the isotropic-nematic phase transition occurring in the system for large values of $k$. Finally, the universality class of the model was found to be the same as for the random percolation model.