A Manhattan appeals court narrowly affirmed a residential burglary conviction Tuesday, even though the defendant had been locked inside the basement of an Upper West Side building and could not access the apartments above.

Applying language from a 19th century Court of Appeals ruling known as the “midnight terror” case, a 3-2 majority of the Appellate Division, First Department, held that the seven-story building, which had a deli on the ground floor and apartments above, was a “dwelling” under Penal Law §140.25(2), and thus the conviction for second-degree burglary, rather than a third-degree count, was warranted.