WASHINGTON—The standoff over border-wall funding has laid bare the dynamics of divided government in Washington. At the center of it all, steering the country, are President Trump and House Speaker Nancy Pelosi, political leaders with little shared history, diametrically opposed ideologies and a willingness to go to the brink to get their way.

They are trying to establish the parameters of their relationship while under pressure from supporters to stand firm and deliver on the competing mandates from voters. Although the...