Officers responded to reports of a gunshot victim at the Studio 6 Motel on V Street near Highway 99 around 11:00 pm on Monday.
When they arrived, they found a 54-year-old man who had been shot in the leg.
Investigators reviewed the surveillance video and discovered the victim was shot as two men robbed him. The man was taken to a nearby hospital and is expected to recover.
Witnesses told police they saw the suspects running north on V Street toward 16th Street.
Detectives received a tip that the men had possibly run into a room at the Motel 6 down the street.
Officers found the two suspects, who have been identified as Tyrece Brewer, 23, and Curtis Davis, 18, and the weapon believed to have been used in the shooting. Both men were taken into custody.
Police say Brewer and Davis were booked into the Merced County Jail for attempted homicide and robbery.