pgfplots: tick marks on axis with fill between

New answer

The behavior you observed was considered a bug which is now fixed with the release of v1.14 of PGFPlots. TeXing your axis on top example now gives this (hopefully desired) result.

image showing the result of <code>axis on top</code> example

Old answer

As percusse has stated in his comment you can use the set layers feature and move the filled are to any layer you like. Here an example where you can play a bit what happens, when you change the layer with the resulting image.

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
    \usetikzlibrary{
        pgfplots.fillbetween,
    }
    \pgfplotsset{compat=1.13}
\begin{document}
    \begin{tikzpicture}[
        fill between/on layer={
%            axis background    % grid and ticks will be above filled area
            axis grid           % only ticks will be above filled area
%            axis ticks         % grid and ticks will be below filled area
%            pre main           % <-- initial value
        },
    ]
        \begin{axis}[
            xmin=0,
            xmax=7,
            ymin=0,
            ymax=30,
            grid=major,
        ]
            \addplot+[name path=A,domain=0:6] {x^2};
            \path[name path=B]
                (\pgfkeysvalueof{/pgfplots/xmin},0) --
                (\pgfkeysvalueof{/pgfplots/xmax},0);
            \addplot[red!10] fill between
                [of=A and B, soft clip={domain=1:5}];

            \coordinate (point to spy) at (1,0);
            \coordinate (show magnification) at (2,20);
        \end{axis}
    \end{tikzpicture}
\end{document}

image showing the result of above code


Usually this should not happen. From the documentation on page 381 about axis on top:

Please note that this feature does not affect plot marks. I think it looks unfamiliar if plot marks are crossed by axis descriptions.

So there seems to be a bug in the fillbetween library. As a workaround you could not use it and instead create the filling differently.

\documentclass{article}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}    

\begin{document}

\begin{tikzpicture}
\begin{axis}[
xmin = 0,
xmax = 7,
ymin = 0,
ymax = 30,
axis on top]
\addplot[fill, lightgray, domain=1:5] {x^2} \closedcycle;
\addplot+[domain=0:6] {x^2};
\end{axis}
\end{tikzpicture}

\end{document}

Output:

plot