Given a point $P$ lying on a line $g,$ and given a circle $K.$ Construct a circle passing through the point $P$ and touching the circle $K$ and the line $g.$
1. **Identify the center and radius of circle \( K \):**
   Let the center of circle \( K \) be \( O \) and its radius be \( r \).

2. **Construct the perpendicular line \( d \):**
   Draw a line \( d \) through the center \( O \) of circle \( K \) that is perpendicular to the given line \( g \). This can be done by constructing the intersection of two chords of \( K \) if the center is not given.

3. **Find the points of intersection:**
   Line \( d \) will intersect circle \( K \) at two points. Let these points be \( A \) and \( B \).

4. **Construct the parallel line \( g' \):**
   Through one of the points of intersection, say \( A \), construct a line \( g' \) that is parallel to \( g \). Since \( g' \) is parallel to \( g \) and passes through \( A \), it is tangent to circle \( K \) at point \( A \).

5. **Inversion with respect to point \( P \):**
   Perform an inversion with center \( P \) that preserves circle \( K \). Under this inversion, the line \( g' \) will map to a circle passing through \( P \) and touching circle \( K \).

6. **Find the images of two points on \( g' \):**
   Select two points on \( g' \), say \( X \) and \( Y \). Under the inversion with center \( P \), these points will map to new points, which we will also call \( X \) and \( Y \) for simplicity.

7. **Construct the desired circle:**
   The circle passing through \( P \) and the images of \( X \) and \( Y \) under the inversion is the required circle. This circle will pass through \( P \), touch the circle \( K \), and be tangent to the line \( g \).

The final answer is the circle passing through \( \boxed{ P } \) and the images of \( X \) and \( Y \) under the inversion.