We give a recursive method for computing all values of a basis of Whittaker functions for unramified principal series invariant under an Iwahori or parahoric subgroup of a split reductive group G over a nonarchimedean local field F. Structures in the proof have surprising analogies to features of certain solvable lattice models. In the case G=GLr\\documentclass[12pt]{minimal} \\usepackage{amsmath} \\usepackage{wasysym} \\usepackage{amsfonts} \\usepackage{amssymb} \\usepackage{amsbsy} \\usepackage{mathrsfs} \\usepackage{upgreek} \\setlength{\\oddsidemargin}{-69pt} \\begin{document}$$G=\ extrm{GL}_r$$\\end{document} we show that there exist solvable lattice models whose partition functions give precisely all of these values. Here ‘solvable’ means that the models have a family of Yang–Baxter equations which imply, among other things, that their partition functions satisfy the same recursions as those for Iwahori or parahoric Whittaker functions. The R-matrices for these Yang–Baxter equations come from a Drinfeld twist of the quantum group Uq(gl^(r|1))\\documentclass[12pt]{minimal} \\usepackage{amsmath} \\usepackage{wasysym} \\usepackage{amsfonts} \\usepackage{amssymb} \\usepackage{amsbsy} \\usepackage{mathrsfs} \\usepackage{upgreek} \\setlength{\\oddsidemargin}{-69pt} \\begin{document}$$U_q(\\widehat{\\mathfrak {gl}}(r|1))$$\\end{document}, which we then connect to the standard intertwining operators on the unramified principal series. We use our results to connect Iwahori and parahoric Whittaker functions to variations of Macdonald polynomials.