The man was stabbed at 10 p.m. Thursday just outside the glass doors to the Boylston Street supermarket. He is in critical condition at Brigham and Women’s Hospital, where he is on a ventilator, prosecutors said.

After Guess stabbed the 30-year-old Cambridge man, he ­returned inside the store to sweep, prosecutors said.

The victim called 911 from his cellphone and directed ­police to his alleged assailant, before he was found moments later, lying on his back, near Boylston and Gloucester streets,
a short distance from the store, prosecutors said.

Authorities discovered two knives near the door to Trader Joe’s, one stained with blood, and found Guess inside the store, sweeping.

He was arraigned on one count of assault and battery with a dangerous weapon in Boston Municipal Court, where Judge Sally Kelly set the $250,000 cash bail requested by Edward Curley, assistant Suffolk district attorney.

Curley said the defendant has a criminal record that dates back to the 1990s and includes drug offenses and property crimes.

At the time of his ­arrest, Guess, who also has an alias, Richard Thomas, was in default on an assault charge in Brockton and a shoplifting charge in Woburn, Curley said. Kelly ordered Guess held without bail on those defaults.

Curley said Guess admitted stabbing the victim with a black folding knife, one of the two knives police recovered.

The defendant’s attorney, Arnold Cohen, pleaded not guilty on his behalf and told Kelly that Guess acted in self-defense.

Authorities say the two men exchanged words when the victim attempted to enter the store as employees were closing for the night.

The clerk, standing at the door, was apparently told not to let anyone else in, but the man entered and made a purchase. As the man was walking out the door, the two ­exchanged words again, said prosecutors.

Curley said the defendant’s guilt is corroborated by his own words, the knife evidence, and the statements by the victim.

But Cohen said that his ­client ­only told the customer to have a nice night and that the customer turned and broke out into a tirade before raising his hands “as if he was going to ­attack Mr. Guess,” Cohen said.

Based on the life-threatening injuries to the victim, the Boston police homicide unit is investigating the case.

The supermarket declined to comment beyond a brief one-sentence statement.

“The unfortunate incident is presently under investigation, and we are fully cooperating with the authorities,” a spokeswoman said.

Guess is due back in court on Feb. 26.

Frequent shoppers at the store expressed shock Friday after learning of the stabbing.

“My general reaction: Why on earth would someone do that?” said Ryan Masterson, 29, of Boston, who works near the store and shops there every other day.

Susan Coppola, 42, of West Roxbury, said she shops at the store about once a week, often stopping to chat with workers.

“I know some of the cashiers on a first-name basis,” she said. “It’s a really friendly store; every­one is nice; I’ve never had any kind of problem in there at all.