I adapt the proof of a more general result: Theorem 4.12 in Chapter XI of K. Kuratowski and A. Mostowski’s book “Set Theory: with an introduction to descriptive set theory” (see page 408).
Claim. $f$ is essentially continuous iff there exists a null set $N$ such that $f|({\bf R}^n-N)$ is continuous.
Proof. ($\Rightarrow$) Let $U_1$, $U_2$, … be an open base of $\bf R$. By assumption, $$f^{-1}(U_n)=(O_n-A_n)\cup B_n,$$ where $O_n$ is open and $A_n$, $B_n$ are null sets. Set $N=\bigcup_nA_n\cup\bigcup_nB_n$, so that $N$ is a null set. We show that $g=f|({\bf R}^n-N)$ is continuous. Let $H\subset\bf R$ be open; we prove that $g^{-1}(H)=f^{-1}(H)-N$ is open in ${\bf R}^n-N$. Now $H=U_{k_1}\cup U_{k_2}\cup\cdots$, and so $$g^{-1}(H)=\bigcup_nf^{-1}(U_{k_n})-N=\bigcup_n\bigl((O_{k_n}-A_{k_n})\cup B_{k_n}\bigr)-N.$$ Since $A_{k_n}\cup B_{k_n}\subset N$, it follows that $$g^{-1}(H)=\bigcup_nO_{k_n}-N,$$ which completes the proof since $\bigcup_nO_{k_n}$ is open.
($\Leftarrow$) Let $N$ be a null set and suppose $g=f|({\bf R}^n-N)$ is continuous. Then, if $H\subset\bf R$ is open, the set $g^{-1}(H)=f^{-1}(H)-N$ is open in ${\bf R}^n-N$; that is, there exists open $O\subset{\bf R}^d$ such that $f^{-1}(H)-N=O-N$. Therefore, $$\begin{align*}
f^{-1}(H) &= (f^{-1}(H)-N)\cup(f^{-1}(H)\cap N)\\
&=(O-N)\cup(f^{-1}(H)\cap N).
\end{align*}$$
Since $N$ is a null set, $f^{-1}(H)\cap N$ is also a null set, and it follows that $f^{-1}(H)\triangle O$ is a null set. $\square$