Mr. Mnuchin has spent the week crisscrossing Pennsylvania Avenue to meet with Ms. Pelosi and the two have talked repeatedly on the phone. On Tuesday, after Mr. Mnuchin briefed Senate Republicans at the Capitol, Ms. Pelosi spontaneously invited him to her office. The two sometimes call each other directly on their cellphones. By Friday evening, Mr. Mnuchin and Ms. Pelosi had spoken by telephone 13 times as they raced to strike an agreement to provide government support to workers and businesses affected by the virus.

The two sides parried behind the scenes as Republicans resisted a broad proposal to provide paid sick leave and pushed for the inclusion of language into the emergency package to ensure that federal funding could not be used for most abortions. At a news conference, Ms. Pelosi called Mr. Mnuchin’s suggested changes to the legislation “very reasonable.”

At first blush, a constructive relationship might seem unlikely. When Mr. Mnuchin and Ms. Pelosi shared a table last year at the annual Alfalfa dinner, Politico quipped that Gérard Araud, the French ambassador sitting between them, had the “most awkward seat.” But Mr. Mnuchin and Ms. Pelosi both hail from California and over the years, they have crossed paths and exchanged pleasantries in social circles.

An aide to Ms. Pelosi said that her relationship with the secretary was “cordial” and “operational” and that she appreciated that he is a realist when it came to recognizing facts for what they are. A senior Treasury official said that Mr. Mnuchin viewed Ms. Pelosi as a “shrewd professional” and someone with whom he had a good personal rapport.

In a White House filled with ideologues, few have been able to work successfully across the aisle. Maneuvering with Congress has not always come easily for Mr. Mnuchin, a former banker, hedge fund manager and Hollywood producer who had never worked in government before he was tapped for Treasury secretary after serving as the finance director of Mr. Trump’s 2016 campaign.

His initial foray into congressional diplomacy was not smooth: Mr. Mnuchin served as chief pitchman for the president’s 2017 tax cut, rankling Democrats by producing a one-page economic assessment of a nearly 500-page bill that claimed the $1.5 trillion package would not add to the budget deficit. When he urged Republican House members to support debt ceiling legislation as a favor to him, they groaned and hissed at the request.

But by last year Mr. Mnuchin found himself on firmer footing. With the country facing the prospect of defaulting on its borrowing obligations, Mr. Mnuchin was assigned by Mr. Trump to work with Ms. Pelosi to reach a budget deal. During a meeting last June in Ms. Pelosi’s office, Mr. Mnuchin impressed the speaker when he said he was prepared to stay until they found a solution, according to a person who heard the exchange.