A man armed with a knife was shot and critically wounded by police during a confrontation Monday afternoon inside a library in the city's Olney section, police said.

Mark Cottman, 31, whose last known address was the 5400 block of Warnock Street in Logan, was shot about 2:40 p.m. after he lunged at an officer with the knife inside the Greater Olney branch library at Fifth Street and Tabor Road, said police spokesman Lt. Frank Vanore.

The violent encounter began a few minutes earlier with police responding to a robbery call at J&K Shoes at 5505 N. Fifth St., just up the street from the library, Vanore said.

Cottman "goes in and [at knifepoint] robs the store," Vanore said. "There is some video there, so they know he perpetrates this."

When police arrived, they were directed by witnesses to the library, where they said the robber had fled, Vanore said.

The officers found him in the children's section in the front of the library, Vanore said. "The defendant was ordered to stand up and show his hands," he said. "The male stood up but did not show the officers the palms of his hands."

An officer approached the suspect and saw an object in his right palm, and she again ordered him to show his hands, Vanore said.

Instead, he rushed toward the officer, Vanore said. She shot him once and he dropped to the floor. He remained in critical condition Monday night at Albert Einstein Medical Center.

The officer, whose name was not released, was not injured.

Vanore said the knife-wielding man had not been near any library patrons during the confrontation.

Vanore said Cottman had been arrested 13 times. Court records show Cottman was in prison several times, including for involuntary deviate sexual intercourse.

Storm Knight, 40, who performs work-study at the library as a student at the Art Institute of Philadelphia, said she was on the second floor in an office when she heard "a big boom."

She asked fellow workers what happened and no one knew, she said. When they went downstairs, they were immediately taken by police to give witness statements.

Knight said no children were in the library at the time of the shooting.

"Thank God. Had everything happened 20 minutes later, we would have been swamped by neighborhood kids," Knight said.

Siobhan A. Reardon, president and director of the Free Library of Philadelphia, said there were about 10 to 12 adult patrons in the library at the time.

Reardon said the library would be closed Tuesday to allow employees time off after "a pretty shocking incident."

As police worked inside the library, children were turned away and told that it was closed for the rest of the day.

The shoe store was closed, but the owner of D&M Imports next door recalled the dramatic events that unfolded. Varughese Thomas, 61, said the shoe-store owner, a Chinese American man he knows only as Mike, came into his import shop and said he had been robbed by a man with a knife.

"The store owner said he looked crazy," Thomas recalled. A woman who saw the armed man said he had what appeared to be a plastic hospital identification band on his wrist, Thomas said.

Following procedure, the officer will be assigned to desk duty while the shooting is investigated by Internal Affairs.

Last week, police shot two suspects, killing one.

Tyree Quiah, 22, was killed during a foot pursuit Thursday night in the city's Frankford section. Police said he was armed with a gun.

The next morning, an officer in South Philadelphia shot and wounded Kevin Rex, 43, when he tried to grab another officer's gun.