  In Part I, we extend our analysis in [arXiv:0807.1107], and show that a
mathematically conjectured geometric Langlands duality for complex surfaces in
[1], and its generalizations -- which relate some cohomology of the moduli
space of certain ("ramified") G-instantons to the integrable representations of
the Langlands dual of certain affine (sub) G-algebras, where G is any compact
Lie group -- can be derived, purely physically, from the principle that the
spacetime BPS spectra of string-dual M-theory compactifications ought to be
equivalent.
  In Part II, to the setup in Part I, we introduce Omega-deformation via
fluxbranes and add half-BPS boundary defects via M9-branes, and show that the
celebrated AGT correspondence in [2, 3], and its generalizations -- which
essentially relate, among other things, some equivariant cohomology of the
moduli space of certain ("ramified") G-instantons to the integrable
representations of the Langlands dual of certain affine W-algebras -- can
likewise be derived from the principle that the spacetime BPS spectra of
string-dual M-theory compactifications ought to be equivalent.
  In Part III, we consider various limits of our setup in Part II, and connect
our story to chiral fermions and integrable systems. Among other things, we
derive the Nekrasov-Okounkov conjecture in [4] -- which relates the topological
string limit of the dual Nekrasov partition function for pure G to the
integrable representations of the Langlands dual of an affine G-algebra -- and
also demonstrate that the Nekrasov-Shatashvili limit of the "fully-ramified"
Nekrasov instanton partition function for pure G is a simultaneous
eigenfunction of the quantum Toda Hamiltonians associated with the Langlands
dual of an affine G-algebra. Via the case with matter, we also make contact
with Hitchin systems and the "ramified" geometric Langlands correspondence for
curves.
