Elvis Costello opened a 10-night run at New York City’s Gramercy Theatre Thursday, the night after Burt Bacharach died, and, as expected, paid tribute to the music legend who was his friend and collaborator since the mid-1990s. He covered three songs that Bacharach had hits with as a songwriter in the 1960s, with the promise of getting to some of the many songs they wrote together later in the run.

“It’s been a tough day,” Costello told the sold-out crowd. “You know, a really great man left us yesterday. And people say, when somebody leaves you who’s a great age, they say, well, it was a good ending. Yeah, but it’s never time to say goodbye to somebody if you love ‘em. And I’m not ashamed to say I did love this man.”

The three songs Costello played in memory of Bacharach were “Baby, It’s You,” which was memorably recorded by both the Shirelles and the Beatles, “Anyone Who Had a Heart,” one of the signature songs by Bacharach and lyricist Hal David that Dionne Warwick had a hit with, and “Please Stay,” a number recorded by the Drifters in 1961 that was one of the late songwriter’s earliest hits.

He added that he was thinking about Jane, Bacharach’s wife, and his three children Raleigh, Oliver and Christopher.

The theme of the Thursday performance was songs written by Costello prior to releasing his debut album, “My Aim is True,” in 1977. He stretched that to include a few songs others had written prior to that date, including a couple by Van Morrison. But inevitably it allowed for the trio of Bacharach classics, two of which Costello had recorded before. He cut “Baby, It’s You” as a duet with Nick Lowe in the 1980s and later recorded “Please Stay” for his “Kojak Variety” all-covers album in the ’90s — both before he actually joined up with Bacharach to write the song “God Give Me Strength” for the film “Grace of My Heart,” followed a few years later by a full collaborative album, “Painted From Memory.”

Elvis Costello at the Gramercy (Adela Loconte)

Costello prefaced the first of the Bacharach songs he performed, “Baby, It’s You,” by saying, “I always like the opportunity to play one of his songs. And I was thinking, I want to sing a gentle song of his… I learned this here song from the Beatles. And you can sing with me if you want.” Indeed, much of the crowd murmured along and added the famous “sha-la-las,” along with the “cheat, cheat” that represents naysayers’ gossip about the couple in the song.

The singer-songwriter’s acerbic side came out when he referred to an obituary that he had read on Thursday, soon after Bacharach’s death was publicly announced in the morning, that contained what he felt was dismissive language.

“I read an extraordinary and, I have to say, not tremendously insightful article in the New York Times… There’s a long list of things that the writer didn’t know or understand,” Costello said, citing “the strange claim that Burt Bacharach, the man who wrote the music for ‘What the World Needs Now Is Love,’ was apolitical.” He waited for the audience’s quiet laugh. “I can’t help you with that one.”

(The Times obit Costello was referring to said that “because of the high gloss and apolitical stance of the songs Mr. Bacharach wrote with his most frequent collaborator, the lyricist Hal David, during an era of confrontation and social upheaval, they were often dismissed as little more than background music by listeners who preferred the hard edge of rock or the intimacy of the singer-songwriter genre. But in hindsight, the Bacharach-David team ranks high in the pantheon of pop songwriting.”)

Costello promised the audience — some of whom had bought a pass for the entire 10-night engagement at the Gramercy — that he would be exploring the catalog of songs that he wrote with Bacharach himself when his longtime pianist Steve Nieve joins the run six nights in.

Even when he first recorded “Baby, It’s You” with Lowe in the ’80s, Costello was no johnny-come-lately to the work of Bacharach. He performed the ballad “I Just Don’t Know What to Do With Myself” with his backing band the Attractions in concert at the very start of his career, as heard in a concert rendition included on the compilation album “Stiffs Live” in 1977.

Versions of all of these original collaborative songs and covers appear on an upcoming four-CD boxed set, “The Songs of Bacharach and Costello.”

Shortly prior to Bacharach’s death, Variety interviewed Costello about the compendium and his overall work with his collaborator, for a story to be published when the set arrives in stores March 3. Look here also for a coming conversation with Costello about why he settled on doing a no-repeats run at the Gramercy where upwards of 200 different songs will be performed over the next two weeks.