Two boys, ages 7 and 11, are accused of trying to rob a woman with a loaded gun, police said Sunday.

The 11-year-old boy had a .22 caliber loaded handgun when officers found him Saturday at the parking lot of a church, police said. Detectives were investigating how the boys obtained a gun.

"Officers told the 11-year-old to keep his hands out of his pockets but he ignored the officers and tried putting his hand back in his pocket," Portland police said in a statement. "Officers grabbed his arms and recovered a cocked and loaded .22 caliber handgun in his pocket."

The boys are accused of trying to carjack a 22-year-old woman who was in her family's truck waiting for her parents at the church parking lot. The woman said the boys then demanded cash and her phone, and that the younger boy told the older one to "show her your piece."

"The woman again refused to give them anything and she drove away, calling 911. As she pulled away, she saw the 11-year-old pull the gun from his pocket," police said.

The boys were apprehended by officers responding to reports of children with guns. When they arrived, the boys tried to run away.

After the boys were caught, officers returned the boys to their families, but the 11-year-old tried to escape his parents' house, police said. Officers later caught him.