LONDON — A 63-year-old man attacked an 18th-century oil painting by Thomas Gainsborough with a sharp object at the National Gallery in London over the weekend, slashing through layers of paint but leaving the canvas underneath intact, the museum said.

The Metropolitan Police identified the attacker as Keith Gregory, saying in a statement that he had slashed Gainsborough’s “Mr. and Mrs. William Hallett,” also known as “The Morning Walk,” on Saturday in the east wing of the museum, which is dedicated to paintings by old masters.

The wing, which was evacuated after the attack, reopened within two hours. The painting was removed from display.

Mr. Gregory, who has no fixed address, was charged on Sunday with “causing criminal damage,” and was to appear in court on Monday morning.