A line $g$ and a point $A$ outside $g$ are given in a plane. A point $P$ moves along $g$. 
Find the locus of the third vertices of equilateral triangles whose two vertices are $A$ and $P$.
1. **Define the coordinates:**
   - Let the point \( A \) be \( (0, a) \).
   - Let the point \( P \) be \( (\lambda, 0) \) on the line \( g \) (the x-axis).

2. **Formulate the problem:**
   - We need to find the locus of the third vertex \( C \) of an equilateral triangle \( \triangle APC \) where \( A \) and \( P \) are two vertices.

3. **Use geometric properties of equilateral triangles:**
   - In an equilateral triangle, all sides are equal, and the angles between any two sides are \( 60^\circ \).

4. **Calculate the coordinates of the third vertex \( C \):**
   - Since \( \triangle APC \) is equilateral, the third vertex \( C \) can be found by rotating point \( P \) around point \( A \) by \( \pm 60^\circ \).

5. **Rotation by \( 60^\circ \):**
   - The rotation matrix for \( 60^\circ \) counterclockwise is:
     \[
     R_{60^\circ} = \begin{pmatrix}
     \cos 60^\circ & -\sin 60^\circ \\
     \sin 60^\circ & \cos 60^\circ
     \end{pmatrix} = \begin{pmatrix}
     \frac{1}{2} & -\frac{\sqrt{3}}{2} \\
     \frac{\sqrt{3}}{2} & \frac{1}{2}
     \end{pmatrix}
     \]
   - The rotation matrix for \( 60^\circ \) clockwise is:
     \[
     R_{-60^\circ} = \begin{pmatrix}
     \cos 60^\circ & \sin 60^\circ \\
     -\sin 60^\circ & \cos 60^\circ
     \end{pmatrix} = \begin{pmatrix}
     \frac{1}{2} & \frac{\sqrt{3}}{2} \\
     -\frac{\sqrt{3}}{2} & \frac{1}{2}
     \end{pmatrix}
     \]

6. **Apply the rotation to point \( P(\lambda, 0) \):**
   - For counterclockwise rotation:
     \[
     C_1 = R_{60^\circ} \begin{pmatrix} \lambda \\ 0 \end{pmatrix} = \begin{pmatrix}
     \frac{1}{2} & -\frac{\sqrt{3}}{2} \\
     \frac{\sqrt{3}}{2} & \frac{1}{2}
     \end{pmatrix} \begin{pmatrix} \lambda \\ 0 \end{pmatrix} = \begin{pmatrix}
     \frac{\lambda}{2} \\
     \frac{\lambda \sqrt{3}}{2}
     \end{pmatrix}
     \]
   - For clockwise rotation:
     \[
     C_2 = R_{-60^\circ} \begin{pmatrix} \lambda \\ 0 \end{pmatrix} = \begin{pmatrix}
     \frac{1}{2} & \frac{\sqrt{3}}{2} \\
     -\frac{\sqrt{3}}{2} & \frac{1}{2}
     \end{pmatrix} \begin{pmatrix} \lambda \\ 0 \end{pmatrix} = \begin{pmatrix}
     \frac{\lambda}{2} \\
     -\frac{\lambda \sqrt{3}}{2}
     \end{pmatrix}
     \]

7. **Translate the coordinates back to the original position:**
   - Since \( A \) is at \( (0, a) \), we need to add this to the rotated coordinates:
     \[
     C_1 = \left( \frac{\lambda}{2}, \frac{\lambda \sqrt{3}}{2} + a \right)
     \]
     \[
     C_2 = \left( \frac{\lambda}{2}, -\frac{\lambda \sqrt{3}}{2} + a \right)
     \]

8. **Find the locus equations:**
   - For \( C_1 \):
     \[
     y = \frac{\sqrt{3}}{2} x + a
     \]
     - Rearrange to get:
     \[
     \sqrt{3} x - y + a = 0
     \]
   - For \( C_2 \):
     \[
     y = -\frac{\sqrt{3}}{2} x + a
     \]
     - Rearrange to get:
     \[
     \sqrt{3} x + y - a = 0
     \]

9. **Combine the results:**
   - The locus of the third vertices of the equilateral triangles is given by the two lines:
     \[
     \sqrt{3} x - y + a = 0
     \]
     \[
     \sqrt{3} x + y - a = 0
     \]

The final answer is \(\boxed{\sqrt{3} x - y + a = 0 \text{ and } \sqrt{3} x + y - a = 0}\).