Police in Queens have taken a suspect into custody after a DNA hit linked him to two sex assaults reported last week in the Rockaway section, sources told The Post.

The suspect, Matthew Johnson, was being questioned at the 101st Precinct in Far Rockaway, after police matched his DNA to that recovered at the crime scenes of two unsolved rapes, according to individuals familiar with the case.

It was unclear why Johnson’s DNA was on file with authorities. He has several arrests, mostly for petty offenses, the sources said.

Two illegal handguns were seized at Johnson’s home when he was arrested, the sources said. In each of the two attacks, the victim was accosted by a man brandishing a gun, before being sexually assaulted.

The first, on Oct. 27, took place at 3 a.m. as the 25-year-old victim exited the Beach 67th Street subway station. She was forced into an alleyway, where the assault took place.

The following day, at 5:21 a.m., a 21-year-old standing at the corner of Beach Channel Drive and Beach 56th Street was forced into a nearby building and assaulted on a sixth floor landing.