WASHINGTON — It’s not every day in Washington that the attorney general dares the speaker of the House to lock him up.

But as he mingled backstage with V.I.P.s at an event honoring law enforcement officers on Capitol Hill on Wednesday morning, Attorney General William P. Barr apparently saw an opportunity for a gag — or was it a taunt? Either way, he gave it a try.

“Madam Speaker,” Mr. Barr said, approaching Speaker Nancy Pelosi of California for a handshake. “Did you bring your handcuffs?”

Ms. Pelosi, whose Democratic caucus is preparing to hold Mr. Barr in contempt of Congress for refusing to hand over Robert S. Mueller III’s full report, had joked last week that the House still had “a little jail” it could put to use, if necessary.