The following proof was inspired by Fedor Petrov's and Gjergji's Zaimi's argument, but it is simpler.
By a scaling argument we may assume $a_i\in[1,A]$, $b_i\in[1,B]$.
The inequality can be rewritten as
$$x^{1/p}y^{1/q} \leq (A^pB^q-1)\sum_{i=1}^n a_ib_i,$$
where
$$x:=p(AB^q-B)\sum_{i=1}^na_i^p\qquad\text{and}\qquad
y:=q(BA^p-A)\sum_{i=1}^nb_i^q.$$
By Young's inequality $x^{1/p}y^{1/q}\le \frac{x}{p}+\frac{y}{q}$, the above follows from
$$\frac{x}{p}+\frac{y}{q}\leq (A^pB^q-1)\sum_{i=1}^n a_ib_i.$$
Therefore it suffices to show, for any $i$,
$$(AB^q-B)a_i^p+(BA^p-A)b_i^q\leq (A^pB^q-1)a_ib_i.$$
The difference LHS-RHS is a convex function of $a_i$ and $b_i$, hence we can assume that
$a_i\in\{1,A\}$, $b_i\in\{1,B\}$. The inequality is trivial becomes an identity when exactly one of $a_i$ and $b_i$ equals 1, while in the other two cases it is equivalent to
$$(1-A^{1-p})(1-B^{1-q})\leq(A-1)(B-1)\leq (A^p-A)(B^q-B).$$
By convexity again,
$$1-A^{1-p}\leq(p-1)(A-1)\leq A^p-A,$$
$$1-B^{1-q}\leq(q-1)(B-1)\leq B^q-B,$$
whence the required inequality follows upon noting that $(p-1)(q-1)=1$.

