(CNN) -- Canadian Prime Minister Justin Trudeau apologized Wednesday after a photo emerged of him wearing brownface during a school event in 2001.
"I shouldn't have done it. I should have known better, but I didn't," he told reporters on an airplane. "And I'm really sorry."
He said it was a racist photo but he didn't consider it racist at the time.
It was a photo taken when he was a teacher in 2001, attending an end-of-the-year gala with an "Arabian Nights" theme, he said.
The future prime minister attended the event with friends and colleagues and was dressed as a character from Aladdin, said Zita Astravas, speaking on behalf of Trudeau's party, the Liberal Party of Canada. He was wearing a turban.
Trudeau said he also put on makeup for a high school talent show in which he sang.
Trudeau is running for reelection. He is in a virtual tie for the election with Conservative Andrew Scheer.
"I stand here before Canadians as I will throughout this campaign and talk about the work we have to do to make a better country together," he said. "And I am going to continue to stay focused on that and continue to work to fight intolerance and discrimination, even though obviously I made a mistake in the past."
The election is October 21.
The leader of the Green Party, Elizabeth May, said she was "deeply shocked by the racism shown in the photograph."
"He must apologize for the harm done and commit to learning and appreciating the requirement to model social justice leadership at all levels of government," May tweeted. "In this matter he has failed."
The existence of the photograph was first reported by Time.
Trudeau, 47, was sworn in as prime minister in November 2015. Trudeau, son of Pierre Trudeau, is the first child of a Canadian prime minister to become prime minister himself.
This is a developing story. Check back for updates.